jorgenschaefer / elpy

Emacs Python Development Environment
GNU General Public License v3.0
1.9k stars 260 forks source link

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

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 init.el:

;; init.el --- Emacs configuration

;; INSTALL PACKAGES
;; --------------------------------------------

(require 'package)

(add-to-list 'package-archives
       '("melpa-stable" . "https://stable.melpa.org/packages/"))

(package-initialize)
(when (not package-archive-contents)
  (package-refresh-contents))

(defvar myPackages
  '(elpy))

(mapc #'(lambda (package)
    (unless (package-installed-p package)
      (package-install package)))
      myPackages)

;; BASIC CUSTOMIZATION
;; --------------------------------------------

;; elpy configuration
(elpy-enable)
;; 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
;;                          ('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

;; init.el ends here

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)

I am using a MacBook Pro (13-inch, Mid 2012) with high sierra 10.13.6.

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

yichao-cai commented 3 years ago

I think this issue is related to this one (https://github.com/jorgenschaefer/elpy/issues/1890). Downgrading jedi to 0.17.2 solve the problem for me.