s g
s g

Reputation: 5667

pip exists, says no module named pip

I have pip installed and can clearly see the file (by using which pip) but, when I go to actually run a command like pip install -r requirements.txt (or even just pip to get help), I get the following error:

Traceback (most recent call last):
  File "/usr/local/bin/pip3", line 7, in <module>
    from pip._internal import main
ModuleNotFoundError: No module named 'pip'

I get this whether I'm using pip 2 or 3. What is going on here? Any way to fix it without reinstalling the whole thing?

Upvotes: 2

Views: 332

Answers (3)

Appyens
Appyens

Reputation: 139

Try this command

python -m pip <action>

Upvotes: 1

s g
s g

Reputation: 5667

Succinct answer - I ran pip -m site to see where my site packages are, and poked around in there and couldn't find pip. It must have gotten deleted...

This makes me wonder, though, why did pip disappear when I ran pip install --upgrade pip as it instructed me to do! 🤔

Upvotes: 1

Ines Tlili
Ines Tlili

Reputation: 810

Force a reinstall by running

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py --force-reinstall

Upvotes: 2

Related Questions