1
votes

The problem is when I run pip3 --version it works fine and produce

pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

So I decided to install pip using sudo apt install python-pip and works fine producing

python-pip is already the newest version (9.0.1-2.3~ubuntu1).

But when I try to run pip --version the following error shows up

Traceback (most recent call last): File "/usr/bin/pip", line 9, in from pip import main ImportError: cannot import name main

I already check this post Error after upgrading pip: cannot import name 'main' , but my problem only occurs when I'm using pip (python 2.7). Any help will be appreciated

1

1 Answers

4
votes

The problem turns out to be the same as bug in pip 10.0 although I'm using pip 18.0, the bug is still there.

The solution is by modifying file: /usr/bin/pip sudo vim /usr/bin/pip
from:

from pip import main
if __name__ == '__main__':
sys.exit(main())

to

from pip import __main__
if __name__ == '__main__':
sys.exit(__main__._main())

credits : ImportError: cannot import name main when running pip --version command in windows7 32 bit