5

I have two versions of python installed on my machine (Ubuntu 14.xx LTE) as well as two versions of pip (one for python 2 and one for python 3). When I run pip --version on the command line I get the following output: pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7). I looked into this directory and it has many other things in it. However I couldn't find pip.py in it. How do I run pip for python 3? Any help is appreciated.

3
  • 2
    pip for python 3 is called pip3 Commented Sep 8, 2015 at 21:30
  • 1
    First of all it may have alias like pip3. But you also may provide full path to it like /usr/lib/python3.4/bin/pip Commented Sep 8, 2015 at 21:31
  • a comment for Debian users: your /usr/bin/pip2 script might have #!/usr/bin/python <- with just "python" and no specific version. Then it will launch the default Python, which is 3 nowadays. So, edit it to #!/usr/bin/python2.7 or whatever Python 2 you have. Commented Jun 17, 2021 at 23:12

2 Answers 2

10

To use another version of pip for python on ubuntu, you can use the python major version after pip. For Example:

pip --version

will return the default version of pip

pip2 --version

will use the Python 2 version of pip, and

pip3 --version

will use Python 3.

Hope this helped!

Sign up to request clarification or add additional context in comments.

1 Comment

Also, you can access pip as a module for different OSes easily for different Python installs. "/path/to/python/executable -m pip --version" works great for Windows versions with multiple Python installs, or if the Python variable is added to the path, then "python2 -m pip" and "python3 -m pip".
0

rename your python.exe for python 3 to python3. Don't forget to put it inside your PATH environment. Just use python for python 2, python3 for python 3.

Their pip are separated, pip for python 2. pip3 for python 3.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.