I just updated from 16.04 to 17.10, and every time I attempt to run any python2.7 command, I'm getting this error:
pip install --upgrade pip
Traceback (most recent call last):
File "/home/XXXX/bin/pip", line 7, in <module>
from pip import main
File "/home/XXXX/local/lib/python2.7/site-packages/pip/__init__.py",
line 5, 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 "/home/XXXX/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
Another user had a similar problem, but this affects any python program I attempt to execute. I can't install anything via pip, or use any python scripts. I really have no idea what to do, assistance would be greatly appreciated.
Output of "python –version" is
Python 2.7.12
however "update python" produces:
python is already the newest version (2.7.14-2ubuntu1).
Best Answer
This isn't an Ubuntu solution, but because this question appears high in search results for the error, I wanted to say that I had this error on OSX because my default system Python was 2.7, and I brew installed "python@2" while installing another package.
If you're on OSX and are using homebrew, check your packages installed with brew by running
brew list
, and if "python@2" appears in that list, and Python 2.7 is your system Python, you can remove the brew installed package withbrew remove python@2 --ignore-dependencies