Elpy: Elpy Unable to locate jedi, rope, autopep8, black, After system upgrade.

Created on 18 May 2020  Â·  17Comments  Â·  Source: jorgenschaefer/elpy

Summary

I recently upgraded Fedora 31 to 32, which comes with Python 3.8 while the earlier version has Python 3.7. In the previous version, everything was working but now I can't seem to be able to use jedi, rope and other python tools from emacs. Even though I have already installed all these tools via pip, as well as refreshed and upgraded all the packages from emacs. Please Help

Steps to reproduce

sudo dnf upgrade --refresh
sudo dnf system-upgrade download releasever=32
sudo dnf system-upgrade reboot

After Reboot

emacs
M-x elpy-config

My configuration

OS = Fedora 32

Python Version = 3.8.2

Emacs Version = 26.3

pip Version = pip 20.1 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)

Result of (elpy-config)

```Elpy Configuration

Emacs.............: 26.3
Elpy..............: 1.33.0
Virtualenv........: None
Interactive Python: jupyter 4.6.3 (/usr/local/bin/jupyter)
RPC virtualenv....: rpc-venv (/home/sbn/.emacs.d/elpy/rpc-venv)
Python...........: python 3.8.2 (/home/sbn/.emacs.d/elpy/rpc-venv/bin/python)
Jedi.............: Not found (0.17.0 available)
Rope.............: Not found (0.17.0 available)
Autopep8.........: Not found (1.5.2 available)
Yapf.............: Not found (0.30.0 available)
Black............: Not found (19.10b0 available)
Syntax checker....: flake8 (/usr/local/bin/flake8)

Warnings

You have not activated a virtual env. While Elpy supports this, it is
often a good idea to work inside a virtual env. You can use M-x
pyvenv-activate or M-x pyvenv-workon to activate a virtual env.

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'.

The jedi package is not available. Completion and code navigation will
not work.

[Install jedi]

The autopep8 package is not available. Commands using this will not
work.

[Install autopep8]

The yapf package is not available. Commands using this will not work.

[Install yapf]

The black package is not available. Commands using this will not work.

[Install black]

Options

`Raised' text indicates buttons; type RET or click mouse-1 on a button
to invoke its action. Invoke [+] to expand a group, and [-] to
collapse an expanded group. Invoke the [Group], [Face], and [Option]
buttons below to edit that item in another window.

## Elpy configuration in my init.el
```;; Python Configurations
(elpy-enable)
(setq python-shell-interpreter "jupyter"
      python-shell-interpreter-args "console --simple-prompt"
      python-shell-prompt-detect-failure-warning nil)
(add-to-list 'python-shell-completion-native-disabled-interpreters
             "jupyter")

(require 'py-autopep8) ;;Auto Format Code to be pep8 Compliant
(add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save)

(add-hook 'elpy-mode-hook '(lambda () (flymake-mode -1))) ;;Disable Flymake in elpy-mode. Let Flycheck Take Over

(add-hook 'inferior-python-mode-hook 'auto-complete-mode) ;; Autocompletion in Ipython

Result of Running pip install -U rope jedi autopep8 black yapf rope

Requirement already up-to-date: jedi in /usr/local/lib/python3.8/site-packages (0.17.0)
Requirement already up-to-date: autopep8 in /usr/local/lib/python3.8/site-packages (1.5.2)
Requirement already up-to-date: black in /usr/local/lib/python3.8/site-packages (19.10b0)
Requirement already up-to-date: yapf in /usr/local/lib/python3.8/site-packages (0.30.0)
Requirement already up-to-date: rope in /usr/local/lib/python3.8/site-packages (0.17.0)
Requirement already satisfied, skipping upgrade: parso>=0.7.0 in /usr/local/lib/python3.8/site-packages (from jedi) (0.7.0)
Requirement already satisfied, skipping upgrade: pycodestyle>=2.5.0 in /usr/local/lib/python3.8/site-packages (from autopep8) (2.6.0)
Requirement already satisfied, skipping upgrade: typed-ast>=1.4.0 in /usr/local/lib64/python3.8/site-packages (from black) (1.4.1)
Requirement already satisfied, skipping upgrade: click>=6.5 in /usr/local/lib/python3.8/site-packages (from black) (7.1.2)
Requirement already satisfied, skipping upgrade: pathspec<1,>=0.6 in /usr/local/lib/python3.8/site-packages (from black) (0.8.0)
Requirement already satisfied, skipping upgrade: attrs>=18.1.0 in /usr/local/lib/python3.8/site-packages (from black) (19.3.0)
Requirement already satisfied, skipping upgrade: regex in /usr/local/lib64/python3.8/site-packages (from black) (2020.5.14)
Requirement already satisfied, skipping upgrade: appdirs in /usr/local/lib/python3.8/site-packages (from black) (1.4.4)
Requirement already satisfied, skipping upgrade: toml>=0.9.4 in /usr/local/lib/python3.8/site-packages (from black) (0.10.1)

Result of Running [Install Black] from elpy-config buffer

python -m pip install black: exited abnormally with code 1. [3 times]

Error Message

/home/sbn/.emacs.d/elpy/rpc-venv/bin/python: No module named pip

Contents of .emacs.d/elpy/rpc-venv/bin

activate.csh
activate.fish
autopep8
black
blackd
easy_install
easy_install-3.7
flake8
pip
pip3
pip3.7
pycodestyle
pyflakes
python
python3
yapf

Please Help!

elpy-config.txt

Most helpful comment

Final Status : Resolved

Cause of issue

After upgrading to Fedora 32, Python 3.7 was removed and instead Python 3.8 was installed. Even though elpy was able to correctly detect the changed version it could not use the new pip to install the required packages.

Brute Force Solution :

  1. Uninstall elpy
    a. Open emacs
    b. Type M-x and then package-list-packages
    c. Find elpy and press d this marks the package for uninstallation. You should see a D next to elpy on the left .
    d. Type x to perform selected action ie uninstall elpy
    e. Follow any other instruction as prompted.
  2. Open you init.el and comment out the elpy section
  3. Navigate to your .emacs.d directory and delete the elpy directory.
  4. Restart emacs
  5. Reinstall elpy by M-x RET then package-install RET and type elpy and RET. Type yes when prompted.
  6. Open you init.el and un-comment out the elpy section.
  7. Relaunch emacs

    Final output of elpy-config

Elpy Configuration

Emacs.............: 26.3
Elpy..............: 1.33.0
Virtualenv........: None
Interactive Python: jupyter 4.6.3 (/usr/local/bin/jupyter)
RPC virtualenv....: rpc-venv (/home/sbn/.emacs.d/elpy/rpc-venv)
 Python...........: python 3.8.2 (/home/sbn/.emacs.d/elpy/rpc-venv/bin/python)
 Jedi.............: 0.17.0
 Rope.............: 0.17.0
 Autopep8.........: 1.5.2
 Yapf.............: 0.30.0
 Black............: 19.10b0
Syntax checker....: flake8 (/usr/local/bin/flake8)

Case resolved, Code Navigation and other features now work.

All 17 comments

It says that ~/.local/bin is not in your path, and thus emacs won't find the executables. Has your system update messed with your paths?

I don't know, do you suggest adding the directory to my path?

What's the output of echo $PATH?

You could try that for debugging. If that works, then you might want to find out why that changed, or just add it, and be done with it

Is there anything in the directory?

Here is the output of echo $PATH -
/usr/share/Modules/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/sbn/bin
and here is the output of ls ~/.local/bin -

distro
easy_install
easy_install-3.7
f2py
f2py3
f2py3.7
fuck
guessit
install_cmdstan
install_cxx_toolchain
iptest
iptest3
ipython
ipython3
jsonschema
jupyter
jupyter-bundlerextension
jupyter-console
jupyter-kernel
jupyter-kernelspec
jupyter-migrate
jupyter-nbconvert
jupyter-nbextension
jupyter-notebook
jupyter-qtconsole
jupyter-run
jupyter-serverextension
jupyter-troubleshoot
jupyter-trust
mako-render
pbr
pygmentize
pylupdate5
pyrcc5
python-argcomplete-check-easy-install-script
python-argcomplete-tcsh
pyuic5
register-python-argcomplete
srt
thefuck

Try adding ~/.local/bin to your path and check again.

The warning states clearly

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'.

Here is the new $PATH
/usr/share/Modules/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/sbn/bin:.local/bin/ and ran elpy-rpc-restart . No change. Still says the same thing

Please check the exec-path emacs variable C-h v exec-path and make sure that directory is included. If it's not you could use something like exec-path-from-shell.

Here is the output of C-h v exec-path

exec-path is a variable defined in ‘C source code’.
Its value is
("/usr/share/Modules/bin" "/usr/local/bin" "/usr/local/sbin" "/usr/bin" "/usr/sbin" ".local/bin/" "/home/sbn/bin" "/usr/libexec/emacs/26.3/x86_64-redhat-linux-gnu")
Original value was 
("/usr/share/Modules/bin" "/usr/local/bin" "/usr/local/sbin" "/usr/bin" "/usr/sbin" ".local/bin" "/home/sbn/bin" "/usr/libexec/emacs/26.3/x86_64-redhat-linux-gnu")

  This variable may be risky if used as a file-local variable.

Documentation:
List of directories to search programs to run in subprocesses.
Each element is a string (directory name) or nil (try default directory).

By default the last element of this list is ‘exec-directory’. The
last element is not always used, for example in shell completion
(‘shell-dynamic-complete-command’).

You can customize this variable.

The directory is included in the exec-path variable

You should also make sure all dependencies that were not found are installed too.

 Jedi.............: Not found (0.17.0 available)
 Rope.............: Not found (0.17.0 available)
 Autopep8.........: Not found (1.5.2 available)
 Yapf.............: Not found (0.30.0 available)
 Black............: Not found (19.10b0 available)

As I have posted in the original post. I have already installed all of these via pip

Check where pip installed those and add that dir to the path.
pip list -v

You should add /home/sbn/.local/bin to your PATH variable, not just .local/bin

Here is the output of pip list -v

autopep8           1.5.2      /usr/local/lib/python3.8/site-packages   pip
black              19.10b0    /usr/local/lib/python3.8/site-packages   pip
jedi               0.17.0     /usr/local/lib/python3.8/site-packages   pip
rope               0.17.0     /usr/local/lib/python3.8/site-packages   pip
yapf               0.30.0     /usr/local/lib/python3.8/site-packages   pip

and here is the PATH
/usr/share/Modules/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:.local/bin/:/usr/local/lib/python3.8/site-packages:/home/sbn/bin

and here is C-h v exec-path

exec-path is a variable defined in ‘C source code’.
Its value is
("/usr/share/Modules/bin" "/usr/local/bin" "/usr/local/sbin" "/usr/bin" "/usr/sbin" ".local/bin/" "/usr/local/lib/python3.8/site-packages" "/home/sbn/bin" "/usr/libexec/emacs/26.3/x86_64-redhat-linux-gnu")
Original value was 
("/usr/share/Modules/bin" "/usr/local/bin" "/usr/local/sbin" "/usr/bin" "/usr/sbin" ".local/bin" "/usr/local/lib/python3.8/site-packages" "/home/sbn/bin" "/usr/libexec/emacs/26.3/x86_64-redhat-linux-gnu")

  This variable may be risky if used as a file-local variable.

Documentation:
List of directories to search programs to run in subprocesses.
Each element is a string (directory name) or nil (try default directory).

By default the last element of this list is ‘exec-directory’. The
last element is not always used, for example in shell completion
(‘shell-dynamic-complete-command’).

You can customize this variable.

Still no change

elpy-config still says Not Found

Your path still doesn't contain the correct path.

/usr/share/Modules/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:.local/bin/:/usr/local/lib/python3.8/site-packages:/home/sbn/bin

should be:

/usr/share/Modules/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/sbn/.local/bin/:/usr/local/lib/python3.8/site-packages:/home/sbn/bin

Changed the PATH as suggested.

Current path

/usr/share/Modules/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/sbn/.local/bin/:/usr/local/lib/python3.8/site-packages:/home/sbn/bin

Current exec-path

exec-path is a variable defined in ‘C source code’.
Its value is
("/usr/share/Modules/bin" "/usr/local/bin" "/usr/local/sbin" "/usr/bin" "/usr/sbin" "/home/sbn/.local/bin/" "/usr/local/lib/python3.8/site-packages" "/home/sbn/bin" "/usr/libexec/emacs/26.3/x86_64-redhat-linux-gnu")
Original value was 
("/usr/share/Modules/bin" "/usr/local/bin" "/usr/local/sbin" "/usr/bin" "/usr/sbin" "/home/sbn/.local/bin" "/usr/local/lib/python3.8/site-packages" "/home/sbn/bin" "/usr/libexec/emacs/26.3/x86_64-redhat-linux-gnu")

  This variable may be risky if used as a file-local variable.

Documentation:
List of directories to search programs to run in subprocesses.
Each element is a string (directory name) or nil (try default directory).

By default the last element of this list is ‘exec-directory’. The
last element is not always used, for example in shell completion
(‘shell-dynamic-complete-command’).

You can customize this variable.


Current elpy-config

Elpy Configuration

Emacs.............: 26.3
Elpy..............: 1.33.0
Virtualenv........: None
Interactive Python: jupyter 4.6.3 (/usr/local/bin/jupyter)
RPC virtualenv....: rpc-venv (/home/sbn/.emacs.d/elpy/rpc-venv)
 Python...........: python 3.8.2 (/home/sbn/.emacs.d/elpy/rpc-venv/bin/python)
 Jedi.............: Not found (0.17.0 available)
 Rope.............: Not found (0.17.0 available)
 Autopep8.........: Not found (1.5.2 available)
 Yapf.............: Not found (0.30.0 available)
 Black............: Not found (19.10b0 available)
Syntax checker....: flake8 (/usr/local/bin/flake8)

Status : No Change, Problem still persists.

Final Status : Resolved

Cause of issue

After upgrading to Fedora 32, Python 3.7 was removed and instead Python 3.8 was installed. Even though elpy was able to correctly detect the changed version it could not use the new pip to install the required packages.

Brute Force Solution :

  1. Uninstall elpy
    a. Open emacs
    b. Type M-x and then package-list-packages
    c. Find elpy and press d this marks the package for uninstallation. You should see a D next to elpy on the left .
    d. Type x to perform selected action ie uninstall elpy
    e. Follow any other instruction as prompted.
  2. Open you init.el and comment out the elpy section
  3. Navigate to your .emacs.d directory and delete the elpy directory.
  4. Restart emacs
  5. Reinstall elpy by M-x RET then package-install RET and type elpy and RET. Type yes when prompted.
  6. Open you init.el and un-comment out the elpy section.
  7. Relaunch emacs

    Final output of elpy-config

Elpy Configuration

Emacs.............: 26.3
Elpy..............: 1.33.0
Virtualenv........: None
Interactive Python: jupyter 4.6.3 (/usr/local/bin/jupyter)
RPC virtualenv....: rpc-venv (/home/sbn/.emacs.d/elpy/rpc-venv)
 Python...........: python 3.8.2 (/home/sbn/.emacs.d/elpy/rpc-venv/bin/python)
 Jedi.............: 0.17.0
 Rope.............: 0.17.0
 Autopep8.........: 1.5.2
 Yapf.............: 0.30.0
 Black............: 19.10b0
Syntax checker....: flake8 (/usr/local/bin/flake8)

Case resolved, Code Navigation and other features now work.

Note for people encountering the same issue:
It might be worth reinstalling only the RPC virtualenv (with M-x elpy-rpc-reinstall-virtualenv) before reinstalling elpy completely.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SergiyKolesnikov picture SergiyKolesnikov  Â·  3Comments

SirSharpest picture SirSharpest  Â·  6Comments

Arseny-N picture Arseny-N  Â·  4Comments

rakanalh picture rakanalh  Â·  5Comments

twangnh picture twangnh  Â·  6Comments