Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use python2.7 pip instead of default pip

I just installed python 2.7 and also pip to the 2.7 site package.

When I get the version with:

pip -V 

It shows:

pip 1.3.1 from /usr/lib/python2.6/site-packages (python 2.6) 

How do I use the 2.7 version of pip located at:

/usr/local/lib/python2.7/site-packages 
like image 763
Atma Avatar asked Oct 08 '14 21:10

Atma


People also ask

How do I change my default pip?

You can use alias pip = 'pip2. 7' Put this in your . bashrc file(If you're using bash,if zsh it should be . zshrc ).

Does Python 2.6 have pip?

pip works with CPython versions 2.6, 2.7, 3.1, 3.2, 3.3, 3.4 and also pypy.


2 Answers

There should be a binary called "pip2.7" installed at some location included within your $PATH variable.

You can find that out by typing

which pip2.7 

This should print something like '/usr/local/bin/pip2.7' to your stdout. If it does not print anything like this, it is not installed. In that case, install it by running

$ wget https://bootstrap.pypa.io/pip/2.7/get-pip.py $ sudo python2.7 get-pip.py 

Now, you should be all set, and

which pip2.7 

should return the correct output.

like image 73
maennel Avatar answered Sep 28 '22 04:09

maennel


An alternative is to call the pip module by using python2.7, as below:

python2.7 -m pip <commands> 

For example, you could run python2.7 -m pip install <package> to install your favorite python modules. Here is a reference: https://stackoverflow.com/a/50017310/4256346.

In case the pip module has not yet been installed for this version of python, you can run the following:

python2.7 -m ensurepip 

Running this command will "bootstrap the pip installer". Note that running this may require administrative privileges (i.e. sudo). Here is a reference: https://docs.python.org/2.7/library/ensurepip.html and another reference https://stackoverflow.com/a/46631019/4256346.

like image 37
Jasha Avatar answered Sep 28 '22 03:09

Jasha