python2.7 broken by weakref import error, please help!
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 with brew remove python@2 --ignore-dependencies
In case you were using a virtual environment, you'll need to re-create it. The other possibility is that you use some source based or side-installed python version which clashes with the system one. In that case you have to sort out that the right folders and paths are configured looked from the various environments.
In my case, it was an error related to the virtual environment. So, creating a new virtual environment worked for me. Here is the list of commands that may help you in the same.
Installing virtual environment:
pip install virtualenv
Creating a new virtual environment:
virtualenv -p {env_name}
Activating the virtual environment:
source env_name/bin/activate
Deactivating your virtual environemnt:
deactivate
Assume you need to recreate virtualenv
:
cd <virtualenv_folder>
virtualenv .