purcell / emacs.d

An Emacs configuration bundle with batteries included
BSD 2-Clause "Simplified" License
6.84k stars 2.05k forks source link

elpy 1.35.0 auto-completion by company is not working #775

Closed yichao-cai closed 3 years ago

yichao-cai commented 3 years ago

Hi,

I encounter an issue where the auto-completion is not working on elpy 1.35.0. There is no prompt-up to show the possible candidates.

This is my elpy configure:

Elpy Configuration

Emacs.............: 27.1
Elpy..............: 1.35.0
Virtualenv........: None
Interactive Python: python 3.8.5 (/Users/yichaocai/miniconda3/bin/python)
RPC virtualenv....: miniconda3 (/Users/yichaocai/miniconda3)
 Python...........: python 3.8.5 (/Users/yichaocai/miniconda3/bin/python)
 Jedi.............: 0.18.0
 Rope.............: 0.19.0
 Autopep8.........: 1.5.6
 Yapf.............: 0.31.0
 Black............: 21.4b0
Syntax checker....: flake8 (/Users/yichaocai/miniconda3/bin/flake8)

Warnings

You have not activated a virtual env. It is not mandatory but often a
good idea to work inside a virtual env. You can use `M-x
pyvenv-activate` or `M-x pyvenv-workon` to activate one.

The directory ~/.local/bin/ is not in your PATH. As there is no active
virtualenv, installing Python packages locally will place executables
in that directory, so Emacs won't find them. If you are missing some
commands, do add this directory to your PATH -- and then do
`elpy-rpc-restart'.

This is the trunk of code in my .emacs that is related to elpy:

;; Load elpy
(use-package elpy
  :ensure t
  :init
  (elpy-enable))
;; Add company backend for elpy solution 1
;; (add-hook 'elpy-mode-hook
;;    (lambda ()
;;      (set (make-local-variable 'company-backends)
;;       '((company-dabbrev-code company-yasnippet elpy-company-backend)))))
;; Add company backend for elpy solution 2
;; (add-hook 'python-mode-hook
;;           (lambda ()
;;             ;; explicitly load company for the occasion when the deferred
;;             ;; loading with use-package hasn't kicked in yet
;;             (company-mode)
;;             (add-to-list 'company-backends
;;                          (company-mode/backend-with-yas 'elpy-company-backend))))
;; Let elpy to find python in current environment
(setq elpy-rpc-virtualenv-path 'current)
;; Set elpy to use the conda python3 instead of system default python2.
;; (setq elpy-rpc-python-command "/Users/yichaocai/miniconda3/bin/python");;<<CHANGE

For the solution 1 (https://github.com/jorgenschaefer/elpy/issues/1359#issue-318317905) and solution 2 (https://github.com/jorgenschaefer/elpy/issues/530#issue-66637739), they are from these two related issues. I tried both of them but failed to resolve the issue.

I also checked in the elpy buffer of the enabled modes to make sure that company is enabled:

Enabled minor modes: Auto-Composition Auto-Compression Auto-Encryption
Blink-Cursor Cl-Old-Struct-Compat Company Desktop-Save Eldoc
Electric-Indent Electric-Pair Elpy File-Name-Shadow Flymake Font-Lock
Global-Eldoc Global-Font-Lock Highlight-Indentation Line-Number
Menu-Bar Mouse-Wheel Override-Global Projectile Pyvenv
Rainbow-Delimiters Recentf Shell-Dirtrack Show-Paren Tool-Bar Tooltip
Transient-Mark Yas Yas-Global

The values of the company-backends is:

Value:
(elpy-company-backend company-bbdb company-eclim company-clang company-xcode company-cmake company-files
              (company-dabbrev-code company-gtags company-etags company-keywords)
              company-oddmuse company-dabbrev)
Original value was 
(company-bbdb company-eclim company-semantic company-clang company-xcode company-cmake company-capf company-files
          (company-dabbrev-code company-gtags company-etags company-keywords)
          company-oddmuse company-dabbrev)
Local in buffer test.py; global value is 
(company-bbdb company-eclim company-semantic company-clang company-xcode company-cmake company-capf company-files
          (company-dabbrev-code company-gtags company-etags company-keywords)
          company-oddmuse company-dabbrev)

How can I config the auto-completion of elpy? Please suggest and thank you very much!

purcell commented 3 years ago

Okay, I don't use elpy in this configuration, so I can't really help you here, sorry.

yichao-cai commented 3 years ago

Oh shoot. I am so sorry. I think I posted this issue wrongly. I would move this one to elpy github repo. Sorry for that!

purcell commented 3 years ago

No worries, good luck