-1

I wanted to usepip today but I get an error like:

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

So I thought I'd purge and re-install (following https://www.rosehosting.com/blog/how-to-install-pip-on-ubuntu-16-04/) but still got:

$ sudo apt-get install python-pip
[sudo] password for ron: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  docutils-common liblept5 libtesseract3 linux-headers-4.4.0-127 linux-headers-4.4.0-127-generic linux-image-4.4.0-127-generic linux-image-extra-4.4.0-127-generic python3-colorama python3-dateutil python3-docutils python3-jmespath python3-pygments python3-roman python3-rsa
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  python-pip
0 upgraded, 1 newly installed, 0 to remove and 6 not upgraded.
Need to get 144 kB of archives.
After this operation, 633 kB of additional disk space will be used.
Get:1 http://ca.archive.ubuntu.com/ubuntu xenial/universe amd64 python-pip all 8.1.1-2 [144 kB]
Fetched 144 kB in 0s (162 kB/s)     
Selecting previously unselected package python-pip.
(Reading database ... 667382 files and directories currently installed.)
Preparing to unpack .../python-pip_8.1.1-2_all.deb ...
Unpacking python-pip (8.1.1-2) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up python-pip (8.1.1-2) ...
ron@regDesktopHome:~/docker$ pip -V
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main

How can I get my pip up & running correctly?

stdcerr
  • 13,725
  • 25
  • 71
  • 128
  • 1
    I'm not familiar with Docker, but maybe you should add pip to your Dockerfile, so Docker knows how to install Pip when recreating your image? – nyanpasu64 Aug 08 '18 at 03:29
  • 1
    @jimbo1qaz this is outside docker and has nothing to do with it, I just happen to be in that directory... – stdcerr Aug 08 '18 at 03:41

1 Answers1

0

I'm not familiar with docker

Try change

from pip import main

to

from pip._internal import main

pip.main is deprecated since pip 10

EDIT

Sorry, I missed that your are using pip 8.1

James Liu
  • 497
  • 3
  • 8