What is going on with pip:

$ pip
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 7, in <module>
    from pip import main
ImportError: cannot import name 'main' from 'pip' (/usr/lib/python3/dist-packages/pip/__init__.py)

$ which pip

2 Answers 2


I had the same error (in a virtualenv, not using the system-wide pip) and I think it was because the version of python installed changed from python 3.6 to 3.7 when I upgraded to 19.04. Re-installing the virtualenv fixed it for me.

Is that version of pip in a virtualenv? My default Ubuntu pip is installed in /usr/bin/, not /usr/local/bin/. If you did you might have to update your version of pip. In the new version of pip installled by Ubuntu the import has been changed to:

from pip._internal import main
  • I now think that it was pyenv that had installed pip under /usr/local. I might have used that to install a newer python at some point. After I manually deleted pip from /usr/local it started to work again as /usr/local comes first in PATH and it masked pip in /usr/bin.
    – juzzlin
    Apr 23, 2019 at 9:45

I had the same problem after upgrading from ubuntu 18.04 to ubuntu 19.04 with virtualenv installed but neither pip nor pip3 was not working. Also, $ which pip3 command was resulting that pip was installed at /usr/local/bin/pip3. I fixed it by reinstalling my virtualenv with its previous name in its directory using below command:

$ python3 -m venv path/to/direcotry/name of my venv

You must log in to answer this question.

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