Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
381 views
in Technique[技术] by (71.8m points)

python - Change default Ubuntu pip to pip2.7

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...