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-pip
it does install, but then running pip or pip3 i get the same error.
#which pip3
/home/myuser/.local/bin/pip3
After upgrading
pip
(orpip3
, in this case) if the following occurs:Force a reinstall of pip:
Verify install:
Now
pip3 install <package>
andpip3 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
Had same problem on macOS as well, it's a common issue across platforms.
I solved this by updating pip via Python, like this:
This command also works. It reinstalls
pip
:Apply these three steps:
/usr/local/bin
by terminalsudo gedit pip
from pip._internal import main
intofrom pip import main
.Check if pip is already installed using
or
If not use this command to install it:
Now you can use
to install packages using pip.
I 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 runpip install
, it might help.A force re-install of
pip
with-H
flag worked for me:The pip version now is 19.0.1:
Change
from pip._internal import main
intofrom pip import main