Forums

PIP does not run - ImportError: cannot import name '_remove_dead_weakref'

When I want to run pip in my virtual environment, I get the following error:

Could not import runpy module
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 14, in <module>
import importlib.machinery # importlib first so we can test #15386 via -m
  File "/home/.../venv/lib/python3.6/importlib/__init__.py", line 57, in <module>
import types
  File "/home/.../venv/lib/python3.6/types.py", line 171, in <module>
import functools as _functools
  File "/home/.../venv/lib/python3.6/functools.py", line 23, in <module>
from weakref import WeakKeyDictionary
  File "/home/.../venv/lib/python3.6/weakref.py", line 12, in <module>
from _weakref import (
ImportError: cannot import name '_remove_dead_weakref'

This is the case for both pip and python -m pip commands. Can you help me resolve it?

how are you running this? your virtualenv seems pretty broken, perhaps try setting up a new one again?

I simply activate my virtualenv and then I type pip and press return.

Yes, your virtualenv seems pretty broken. Try setting up a new one. *setting up a new on PythonAnywhere, just in case you had copied over a virtualenv from a different machine. (that wouldn't work)