Sign in

Jedi stopped working after upgrading Linux

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/\\\", line 72, in <module>
from pip.log import logger
File \\\"/home/****/.emacs.d/.python-environments/default/local/lib/python2.7/site-packages/pip/\\\", line 6, in <module>
import logging
File \\\"/usr/lib/python2.7/logging/\\\", line 26, in <module>
import sys, os, time, cStringIO, traceback, warnings, weakref, collections
File \\\"/usr/lib/python2.7/\\\", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref


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:

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!

Web developer, Arabic Native, open-source enthusiastic, trying to do things the right way.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store