[英]pip3.4 -V refers to python2.7 installation
Edit-rephrased question to be less misleading编辑改写的问题以减少误导
Is there a difference between pip3 and pip2? pip3 和 pip2 之间有区别吗?
pip2 -V
and pip3-V
both produce the output pip2 -V
和pip3-V
都产生输出
pip 7.1.0 from /usr/lib/python2.7/site-packages (python 2.7)来自 /usr/lib/python2.7/site-packages (python 2.7) 的 pip 7.1.0
Old question below下面的老问题
I have seen recommendations to set up a python3 virtualenv using pip3, but when I type我已经看到使用 pip3 设置 python3 virtualenv 的建议,但是当我输入时
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
.这与我从
pip -V
和pip2 -V
获得的输出完全相同。 My python3 installation works fine.我的 python3 安装工作正常。 What's the deal?
这是怎么回事? Is pip, pip2, and pip3, actually the same thing?
pip、pip2 和 pip3,实际上是同一个东西吗? Afterall https://pip.pypa.io/en/stable/index.html , only mentions pip.
毕竟https://pip.pypa.io/en/stable/index.html ,只提到了 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更奇怪的是,在我的
/usr/bin
文件夹中,我可以看到我的 pip3 比我的 pip3.4 二进制文件旧——这解释了为什么pip3 -V
失败
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?
pip3 语法是多余的,还是我的系统有问题? I use opensuse 13.2
我使用opensuse 13.2
In Debian, I found three short files in /usr/local/bin: pip;在Debian中,我在/usr/local/bin中发现了三个短文件:pip; pip3;
pip3; and pip3.4.
和 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通过将 pip3(使用 sudo)的第一个 shebang 行更改为
#!/usr/bin/python3
Then ensuring that the original pip was explicitly然后确保原始 pip 是明确的
#!/usr/bin/python2
All of my similar confusion and errors disappeared.我所有类似的困惑和错误都消失了。
I was struggling with the same issue on my EC2 and finally found the solution to it.我在 EC2 上遇到了同样的问题,终于找到了解决方案。 You can use it in following way-
您可以通过以下方式使用它-
python3 -m pip <install> <library>
adding python3 -m before pip calls pip3 from the correct location.在 pip 从正确位置调用 pip3 之前添加 python3 -m 。 You can check its location as follows-
您可以按如下方式检查其位置-
python3 -m pip -V
pip 19.0.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
After reinstalling python3-pip
(opensuse package) pip3 -V
and pip3.4 -V
produce correct output重新安装
python3-pip
(opensuse package) pip3 -V
和pip3.4 -V
产生正确的输出
pip 7.1.0 from /usr/lib/python3.4/site-packages (python 3.4)
I had actually also uninstalled pip2 in the process and strangely reinstalling pip2 with python get-pip
( get-pip ) changed my newly working pip3.4 to point to the python2 site-packages again.我实际上也在这个过程中卸载了 pip2 并且奇怪地用
python get-pip
( get-pip ) 重新安装了 pip2 改变了我新工作的 pip3.4 再次指向 python2 站点包。 This I just changed by deleting the wrong pip3.4 and making a symlink to pip3我只是通过删除错误的 pip3.4 并创建指向 pip3 的符号链接来更改
您可以使用--python=python3
标志来指定要使用的 Python 版本。
I too was facing the same problem, the following aliasing helped.我也面临着同样的问题,以下别名有帮助。
alias pip3="python3 -m pip"别名 pip3="python3 -m pip"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.