Change default Ubuntu pip to pip2.7
Solution 1
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)
Solution 2
-
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,defaultroot
.So if you have to change user toroot
,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.
Related videos on Youtube
Andres
Updated on September 15, 2022Comments
-
Andres over 1 year
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 getpip 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
-
Carl Smith about 4 yearsIn step #3 I suggset making a symlink (
sudo rm /usr/local/bin/pip; sudo ln -s /usr/local/bin/pip2.7 /usr/local/bin/pip
) instead of thecp
because 1) there's no need to duplicate the data and moreover 2) with thecp
approach the pip in your path will not reflect any changes to /usr/local/bin/pip2.7 e.g. trying to remove it.