简体   繁体   English

pip3.4 -V 指的是python2.7安装

[英]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 -Vpip3-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 -Vpip2 -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 -Vpip3.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.

相关问题 pip 为 python2.7 而不是 python3.4 安装模块 - pip installs modules for python2.7 instead of python3.4 适用于Python2.7、3.4的pip安装/升级错误 - pip install/upgrade error for Python2.7, 3.4 SSL证书的pip3.4问题,但不是pip - pip3.4 issue with SSL certificate but NOT pip Python 3.4 和 2.7 安装没有 Script 文件夹,也没有安装 pip - Python 3.4 and 2.7 installation no Script folder and no pip installed python&linux pip始终尝试使用python2.7而不是3.4 - python&linux pip always try to use python2.7 instead of 3.4 Centos 6 - sudo在为Python 3.4安装mysqlclient时无法识别pip3.4 - Centos 6 - sudo doesn't recognise pip3.4 when installing mysqlclient for Python 3.4 如何在我当前的mac(而不是2.6)python2.7安装中创建pip安装python模块? - How to make pip install python modules in my current python2.7 installation on mac (instead of 2.6)? pip安装/usr/local/opt/python/bin/python2.7:错误的解释器:没有这样的文件或目录 - pip installation /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory 尝试使用pip3.4在CentOS 5.11 Server中安装python模块(beautifulsoup)时出错 - Error when trying to install python module (beautifulsoup) in CentOS 5.11 Server using pip3.4 pip适用于python2.7但不适用于3.5 - pip works for python2.7 but not 3.5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM