Jedi stopped working after upgrading Linux

Ahmad Essam
2 min readDec 1, 2020

--

I recently made a clean install of Debian 10 (Buster). I migrated my emacs.d and .emacs hoping that everything will work as usual. I didn’t have much trouble with Emacs except for Jedi Server, which is responsible for Python auto-completion, has stopped working. It took me some time to fix this problem, and I am posting the fix hoping it will save someone else’s time.

Error Message

I tried to reinstall Jedi, the package installs fine, but when I tried jedi:install-server I got this error:

Running: pip install --upgrade /home/****/.emacs.d/elpa/jedi-core-20191011.1750/...Done
deferred error : (error "Deferred process exited abnormally:
command: /home/****/.emacs.d/.python-environments/default/bin/pip
exit status: exit 1
event: exited abnormally with code 1
buffer contents: \"Traceback (most recent call last):
File \\\"/home/****/.emacs.d/.python-environments/default/bin/pip\\\", line 7, in <module>
from pip import main
File \\\"/home/****/.emacs.d/.python-environments/default/local/lib/python2.7/site-packages/pip/__init__.py\\\", line 72, in <module>
from pip.log import logger
File \\\"/home/****/.emacs.d/.python-environments/default/local/lib/python2.7/site-packages/pip/log.py\\\", line 6, in <module>
import logging
File \\\"/usr/lib/python2.7/logging/__init__.py\\\", line 26, in <module>
import sys, os, time, cStringIO, traceback, warnings, weakref, collections
File \\\"/usr/lib/python2.7/weakref.py\\\", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
\"")

Solution

After googling around, I found my solution. I needed to install virtualenv as it is required by Jedi, and also fixing the python environment in .emacs.d.

You can install virtualenv using the package manager:

sudo apt install virtualenv

Then apply this command replacing [USER] with your home directory:

virtualenv --system-site-packages /home/[USER]/.emacs.d/.python-environments/default

This should fix your problem!

To understand what the last command does, you can check the man page:

--system-site-packages
Give access to the global site-packages modules to the virtual environment.

It seems like the Python environment created in .emacs.d didn’t have access to the site-packages modules, and this command fixed it.

Hope this fix saved your time!

--

--

Ahmad Essam

Software Engineer, Web developer, Arabic Native, Trying to reach the right balance in everything.