Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change default Ubuntu pip to pip2.7

Tags:

python

pip

As the title says, is there a way to change the default pip to pip2.7

When I run sudo which pip, I get /usr/local/bin/pip

When I run sudo pip -V, I get pip 1.5.6 from /usr/lib/python3/dist-packages (python 3.4)

If there is no problem at all with this mixed version, please do tell. If there is a problem with downloading dependencies from different pip versions, how can I change to pip2.7?

I know I can pip2.7 install somePackage but I don't like it. I feel I could forget to do this at any point.

Other info: Ubuntu 15.10

like image 824
Andres Avatar asked Mar 18 '17 06:03

Andres


2 Answers

Concise Answer

1.  Locate pip:

$ which pip
/usr/local/bin/pip

2.  List all pips in location learned above:

$ ls /usr/local/bin/pip*
/usr/local/bin/pip   /usr/local/bin/pip2.7  /usr/local/bin/pip3.5
/usr/local/bin/pip2  /usr/local/bin/pip3

3.  Select which one should be your default, i.e. /usr/local/bin/pip2.7, and copy it into pip:

$ sudo cp /usr/local/bin/pip2.7 /usr/local/bin/pip

Verify:

$ pip -V
pip 10.0.1 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
like image 130
Apollys supports Monica Avatar answered Oct 18 '22 16:10

Apollys supports Monica


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

    By the way,you should know that sudo command change current user,default root.So if you have to change user to root,maybe you should put it in /root/.bashrc

  • Or you can make a link

    ln -s /usr/local/bin/pip2.7 /usr/local/bin/pip
    

Also you can try to use virtualenv,it's the best choice for multiple versions in my opinion.

like image 24
McGrady Avatar answered Oct 18 '22 16:10

McGrady