Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to override the pip command to Python3.x instead of Python2.7?

I am using OSX and I have pip installed for both Python3.5 and Python2.7. I know I can run the command pip2 to use Python2 and when I use the command pip3 Python3.x will be used. The problem is that the default of pip is set to Python2.7 and I want it to be Python3.x.

How can I change that?

edit: No, I am not running a virtual environment yet. If it was a virtual environment I could just run Python3.x and forget all about Python2.7, unfortunately since OSX requires Python2.7 for it's use I can't do that. Hence why I'm asking this.

Thanks for the answer. I however don't want to change what running python does. Instead I would like to change the path that running pip takes. At the moment pip -V shows me pip 8.1.2 from /Library/Python/2.7/site-packages (python 2.7), but I am looking for pip 8.1.2 from /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (python 3.5) I am sure there has to be a way to do this. Any ideas?

like image 843
loki l Avatar asked Aug 14 '16 00:08

loki l


People also ask

How do I switch from pip to Python 3?

Install setuptools for Python3 : apt-get install python3-setuptools. Now pip for Python3 could be installed by: python3 -m easy_install pip. Now you can use pip with the specific version of Python to install package for Python 3 by: pip-3.2 install [package]

How do I use python3 instead of python2?

If you are using Linux, add the following into into ~/. bashrc alias python=python3 Restart the shell and type python and python3 should start instead of python2.

Does pip use python3 or python2?

The approach you should take is to install pip for Python 3.2. Then, you can install things for Python 3.2 with pip-3.2 , and install things for Python 2-7 with pip-2.7 .

How do I upgrade pip to a specific version?

You can run “pip install --upgrade pip” to install and use the new version of pip. To update pip2 or pip3 using this command, only replace the first pip with the pip version.


1 Answers

Run this:

pip3 install --upgrade --force pip 

or even more explicit:

python3 -m pip install --upgrade --force pip 

This will install pip for Python 3 and make Python 3 version of pip default.

Validate with:

pip -V 
like image 147
Andrey Stukalenko Avatar answered Sep 26 '22 01:09

Andrey Stukalenko