0

After upgrading pip3 using $ pip3 install --upgrade pip, pip3 fails to work. And throws this: Error Command:

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

it's having the same issue again even after removing the pip3 and reinstalling it.

Somewhere someone suggested to change the from pip import main to from pip._internal import main. But still it didn't work.

4
  • How did you install pip3 in the first place? How did you reinstall it? What version of Ubuntu are you using? What is the output of type -a pip pip3?
    – wjandrea
    Jan 8, 2019 at 19:15
  • I'm using Ubuntu 18.04 LTS. I've both Python 3.6 (as it comes pre-installed with the OS) and Python 3.7 (that I installed separately using this). I used sudo apt-get install python3-pip to install pip3. I did sudo apt purge python3-pip and sudo rm -rf '/usr/lib/python3/dist-packages/pip' to remove it and again used sudo apt-get install python3-pip to reinstall it. But still getting the same error. And the output for this type -a pip pip3 is, pip is /usr/bin/pip and pip3 is /usr/bin/pip3
    – wgetdj
    Jan 8, 2019 at 20:36
  • Are you sure you ran pip3 install --upgrade pip to upgrade pip? Cause for upgrading the system version, you would need to use sudo pip3 install --upgrade pip, or for installing/upgrading your user version, you would need pip3 install --upgrade --user pip.
    – wjandrea
    Jan 9, 2019 at 17:54
  • stackoverflow.com/questions/49836676/…
    – g_p
    Aug 8, 2023 at 13:26

1 Answer 1

0

Your system-wide pip3 executable is still old and located at /usr/bin/pip3:

$ ll `which pip3`
-rwxr-xr-x 1 root root 293 May 16  2018 /usr/bin/pip3*

Try updating using sudo:

$ sudo pip3 install --upgrade pip

Then your updated pip3 executable should be placed at /usr/local/bin/pip3:

$ ll `which pip3`
-rwxr-xr-x 1 root root 216 Jan  8 20:46 /usr/local/bin/pip3*

and will be used by default.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .