The Python interpreter could not find the elpy module.
Summary
I'm setting things up on a fresh ubuntu machine. Elpy interrupts frequently when editing python files, so I checked elpy config and got the warning message shown below.
Part of the warning says that pip is not installed. However I can call pip from both system python and the python used as part of the virtualenv I activated with elpy.
Steps to reproduce
See above. Not sure this is easily reproducible.
My configuration
OS
Ubuntu (name_redacted) steve@nerd:~/name_redacted$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.2 LTS Release: 20.04 Codename: focal
Result of (elpy-config)
Elpy Configuration
Emacs.............: 26.3
Elpy..............: Not found (Python), 1.32.0 (Emacs Lisp)
Virtualenv........: name_redacted (/home/steve/.virtualenvs/name_redacted)
Interactive Python: python3 3.8.5 (/home/steve/.virtualenvs/name_redacted/bin/python3)
RPC virtualenv....: system (/usr)
Python...........: python3 3.8.5 (/usr/bin/python3)
Jedi.............: 0.18.0
Rope.............: 0.18.0
Autopep8.........: 1.5.5
Yapf.............: 0.30.0
Black............: 20.8b1
Syntax checker....: flake8 (/usr/bin/flake8)
Warnings
The Python interpreter could not find the elpy module. Please report to:
https://github.com/jorgenschaefer/elpy/issues/new.
Pip doesn't seem to be installed in the dedicated virtualenv created by Elpy
(/usr). This will prevent some features from working properly (completion,
documentation, reformatting, ...). You can try reinstalling the virtualenv with
`elpy-rpc-reinstall-virtualenv'. If the problem persists, please report on
Elpy's github page.
Elpy configuration in my init.el
here are all the lines that mention elpy.
(elpy-enable)
(setq elpy-rpc-backend "jedi")
(require 'ein)
;; Set the fill column to 79
(add-hook 'python-mode-hook
(lambda () (interactive)
(set-fill-column 79)
))
(define-key elpy-mode-map (kbd "M-.") 'elpy-goto-assignment)
;; Lines below this point appear to have been set automatically
'(elpy-rpc-python-command "python3")
'(package-selected-packages
(quote
(super-save rtags modern-cpp-font-lock ess ein elpy auctex)))
I have a similar setup, but seemingly the same issue:
Elpy Configuration
Emacs.............: 27.1
Elpy..............: Not found (Python), 1.35.0 (Emacs Lisp)
Virtualenv........: rpc-venv (/home/user/.emacs.d/elpy/rpc-venv)
Interactive Python: python 3.8.6 (/home/user/.emacs.d/elpy/rpc-venv/bin/python)
RPC virtualenv....: rpc-venv (/home/user/.emacs.d/elpy/rpc-venv)
Python...........: python3 3.8.6 (/home/user/.emacs.d/elpy/rpc-venv/bin/python3)
Jedi.............: Not found (0.18.0 available)
Rope.............: Not found (0.18.0 available)
Autopep8.........: Not found (1.5.6 available)
Yapf.............: Not found (0.31.0 available)
Black............: Not found (20.8b1 available)
Syntax checker....: Not found (flake8)
Warnings
The Python interpreter could not find the elpy module. Please report
to: https://github.com/jorgenschaefer/elpy/issues/new.
I've tried to run pip3 from the virtualenv created by elpy, and am greeted with the following:
# In ~/.emacs.d/elpy/rpc-venv
$ source ./bin/activate
$ pip3
Traceback (most recent call last):
File "/home/user/.emacs.d/elpy/rpc-venv/bin/pip3", line 5, in <module>
from pip._internal.cli.main import main
File "/home/user/.emacs.d/elpy/rpc-venv/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/home/user/.emacs.d/elpy/rpc-venv/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/home/user/.emacs.d/elpy/rpc-venv/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/home/user/.emacs.d/elpy/rpc-venv/lib/python3.8/site-packages/pip/_internal/cli/cmdoptions.py", line 24, in <module>
from pip._internal.cli.progress_bars import BAR_TYPES
File "/home/user/.emacs.d/elpy/rpc-venv/lib/python3.8/site-packages/pip/_internal/cli/progress_bars.py", line 7, in <module>
from pip._vendor import six
ImportError: cannot import name 'six' from 'pip._vendor' (/home/user/.emacs.d/elpy/rpc-venv/lib/python3.8/site-packages/pip/_vendor/__init__.py)
This is immediately after the elpy package offers to install the packages for me. In the Messages buffer I see
Automatically install the RPC dependencies from PyPI (needed for completion, autoformatting and documentation) ? (y or n) y
Elpy is installing the RPC dependencies...
Elpy failed to install some of the RPC dependencies, please use ‘elpy-config’ to install them.
Done
If I try to create a venv manually then pip works as expected; it's just the elpy created venv that has this issue. If I try to create a venv from scratch manually, then elpy detects I haven't installed the requisite packages, but removes and recreates the venv (with the issue above) rather than installs the packages required.
I hope I've given enough information here. If there's something missing please let me know.
Should probably say that I installed the emacs27 on Ubuntu 20.10 package via the PPA.
Huh, on a whim I installed emacs-snapshot, and it works:
Elpy Configuration
Emacs.............: 28.0.50
Elpy..............: 1.35.0
Virtualenv........: None
Interactive Python: python3 3.8.6 (/usr/bin/python3)
RPC virtualenv....: rpc-venv (/home/user/.emacs.d/elpy/rpc-venv)
Python...........: python3 3.8.6 (/home/user/.emacs.d/elpy/rpc-venv/bin/python3)
Jedi.............: Not found (0.18.0 available)
Rope.............: Not found (0.18.0 available)
Autopep8.........: Not found (1.5.6 available)
Yapf.............: Not found (0.31.0 available)
Black............: Not found (20.8b1 available)
Syntax checker....: Not found (flake8)
Same .emacs.d. All I needed to do was delete the elpy directory contained within it and have elpy recreate it. I hope this is useful for someone because I'm now happy.