Running pip or pip3 results with:
Traceback (most recent call last):
File "/home/myuser/.local/bin/pip", line 7, in <module>
from pip._internal import main
ImportError: No module named 'pip._internal'I had issues with this, and uninstalled pip3, but when i try to install it again using
sudo apt-get -y install python3-pipit does install, but then running pip or pip3 i get the same error.
#which pip3
/home/myuser/.local/bin/pip3 12 8 Answers
After upgrading pip (or pip3, in this case) if the following occurs:
$ ~ pip3 -V
Traceback (most recent call last): File "/usr/local/bin/pip", line 7, in <module> from pip._internal import main
ModuleNotFoundError: No module named 'pip._internal'Force a reinstall of pip:
curl -o get-pip.py
python3 get-pip.py --force-reinstallVerify install:
$ ~ pip3 -V
pip 10.0.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)Now pip3 install <package> and pip3 install --user <package> (for user-level installs) will work correctly.
There should never, ever be any reason you need to run pip in elevated mode.
For Python 2.7
curl -o get-pip.py
python get-pip.py --force-reinstallHad same problem on macOS as well, it's a common issue across platforms.
12I solved this by updating pip via Python, like this:
python2 -m pip install --user --upgrade pip
python3 -m pip install --user --upgrade pip 2 This command also works. It reinstalls pip:
sudo easy_install pip 6 Apply these three steps:
- Go to
/usr/local/binby terminal - Execute
sudo gedit pip - Change the
from pip._internal import mainintofrom pip import main.
Check if pip is already installed using
pip3 -V or
pip3 --versionIf not use this command to install it:
sudo apt install python3-pipNow you can use
python3 -m pip install packageNameto install packages using pip.
1I got the same problem as you just now, I found the reason is that you are working without superuser privilege since some internal python packages or modules are installed under superuser privilege.
So you can try by fist entering sudo su, then enter your password, and run pip install, it might help.
The pip version now is 19.0.1:
which pip3
#/home/xxx/.local/bin/pip3
vim /home/xxx/.local/bin/pip3Change from pip._internal import main into from pip import main
A force re-install of pip with -H flag worked for me:
sudo -H python3.7 get-pip.py --force-reinstall 0