I have a problem when I try to use pip in any way. I'm using Ubuntu 16.04.4
I should say that I've used it already, and I never had any problem, but starting today when I use any command I always get the same error (as an example using pip --upgrade
).
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in <module>
from pip._internal import main
ImportError: No module named _internal
I have tried doing sudo apt-get remove python-pip
followed by sudo apt-get install python-pip
but nothing changed.
Thank you for your time!
I've seen this issue when
PYTHONPATH
was set to include the built-insite-packages
directory. Since Python looks there automatically it is unnecessary and can be removed.In file "/usr/local/bin/pip" change
from pip._internal import main
tofrom pip import main
I just encountered the same problem and in my case, it turns out this is a conflict between the python installation in my virtualenv and the site-wide python (Ubuntu). What solves it for me is to run pip in this way, to force usage of the correct python installation (in my vortualenv):
instead of
I realised this when I tried to follow some of the answers here that suggest re-installing pip and the error output I got was pointing to an existing site-wide python library path although I had activated my virtualenv. Worth trying before deleting and re-installing stuff.
(On windows) not sure why this was happening but I had my PYTHONPATH setup to point to c:\python27 where python was installed. in combination with virtualenv this produced the mentioned bug.
resolved by removing the PYTHONPATH env var all together
The following solution solved the problem on my machine for python2.7 "$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py" and then "$ sudo python2.7 get-pip.py --force-reinstall"
my solution: first step like most other answer:
second, add soft link