I do not know what has happened because this used to work fine but I'm now experiencing a problem where I am running python2.7 but for some reason pip is installing in my python 3.5 dist-packages.

At least, I think this is the case based on when I type python -V I get Python 2.7.10 and when I type pip -V I get pip 8.1.2 from /usr/local/lib/python3.5/dist-packages (python 3.5)

This is causing me knock on problems when setting up virtualenv etc. I've tried uninstalling and installing pip but it is still going back to 3.5. Could I have some advice please.

  • Which one of python-pip and python3-pip (or both) do you have installed?
    – fkraiem
    Jul 12, 2016 at 10:13
  • I've only deliberately installed python-pip using sudo apt-get install pip but I've just checked and I have the latest versions of both installed
    – HenryM
    Jul 12, 2016 at 10:20
  • So I've just run sudo apt-get remove python3-pip but when I try pip -V I get the same directory still
    – HenryM
    Jul 12, 2016 at 10:22
  • I've now completely removed python3.5 and when I try pip -V I get -bash: /usr/local/bin/pip: /usr/bin/python3.5: bad interpreter: No such file or directory but if I try to install pip I'm messaged it is already there. Obviously a path issue, but how do I change it?
    – HenryM
    Jul 12, 2016 at 10:46
  • @HenryM sudo apt-get install pip in fact wouldn't work because there is no package named pip in the Ubuntu repositories. You probably meant sudo apt-get install python-pip (for Python 2) or sudo apt-get install python3-pip (for Python 3). Regardless, do you recall ever upgrading pip? If so, how did you upgrade pip?
    – edwinksl
    Jul 12, 2016 at 17:30

1 Answer 1


If python2 and python3 are both installed, and pip for both has been installed, then there should be a separate pip2 and pip3 command that you can use, for the corresponding version of python.

Note: you have to explicitly install both pip versions: apt-get install python-pip for python2, and apt-get install python3-pip for python3.

Alternatively (but still requiring apt-get install of pip), you can use the pip module from your python executable directly, if you have Python 2.7.9 and later (on the python2 series), or Python 3.4+.

For example, on Ubuntu 16.04, after installing/upgrading python2 and python3 and both pip versions:

$ pip --version 
pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)

$ pip3 --version 
pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5)

$ python2 -m pip --version 
pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)

$ python3 -m pip --version 
pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.