Home > Back-end >  ModuleNotFoundError: No module named 'pip._internal'
ModuleNotFoundError: No module named 'pip._internal'

Time:11-03

Recently I updated Python version Python 3.9.14 from Python3.6. I am running django project, so while running it and also while installing any dependencies, getting this error message - ModuleNotFoundError: No module named 'pip._internal' How to solve this. Getting the below error for pip3 version:

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

I tried python3 -m pip3 install --upgrade pip3 , but I got:

/usr/bin/python3: No module named pip
/usr/bin/python3: No module named pip3

Thank you

CodePudding user response:

I've tried this solution previously and it works:

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

CodePudding user response:

First, you want:

python3 -m pip install --upgrade pip
            # ^ note no 3           ^ in either place

since the module is always named pip, it's just the command line utility that might be named pip3.

Second, if that still fails, you've got a pip3 installed for a version of Python that does not match the version you get when you run python3 itself, and that version, for whatever reason, neglected to ship with pip by default.

The best solution, if available, is to install your distro's corresponding pip (often named something like python3-pip or the like). If that fails, you can run:

python3 -mensurepip

to have Python itself attempt to fix up/install the pip it should have shipped with (you may want to run this with sudo or the like so it can be installed globally).

  • Related