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
403 views
in Technique[技术] by (71.8m points)

python - pip3.4 -V refers to python2.7 installation

Edit-rephrased question to be less misleading

Is there a difference between pip3 and pip2? pip2 -V and pip3-V both produce the output

pip 7.1.0 from /usr/lib/python2.7/site-packages (python 2.7)

Old question below

I have seen recommendations to set up a python3 virtualenv using pip3, but when I type

pip3.4 -V

I get the output

pip 7.1.0 from /usr/lib/python2.7/site-packages (python 2.7)

Which is exactly the same output I get from pip -V and pip2 -V. My python3 installation works fine. What's the deal? Is pip, pip2, and pip3, actually the same thing? Afterall https://pip.pypa.io/en/stable/index.html, only mentions pip. Furthermore strangely, in my /usr/bin folder, I can see my pip3 is older than my pip3.4 binary -- which explains why pip3 -V fails with

pkg_resources.DistributionNotFound: pip==1.5.6

So what is the deal? is the pip3 syntax redundant, or is there something wrong with my system? I use opensuse 13.2

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

In Debian, I found three short files in /usr/local/bin: pip; pip3; and pip3.4. All were identical:

#!/usr/bin/python

# -*- coding: utf-8 -*-
import re
import sys

from pip import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script.pyw|.exe)?$', '', sys.argv[0])
    sys.exit(main())

By changing the very first shebang line of pip3 (with sudo) to

#!/usr/bin/python3

Then ensuring that the original pip was explicitly

#!/usr/bin/python2

All of my similar confusion and errors disappeared.


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

...