简体   繁体   English

我的Python安装使用哪个版本的Pip?

[英]Which version of Pip to use with my Python installs?

Being new to Python, I'd love to clear up a few points that I couldn't get from reading various articles and tutorials. 作为Python的新手,我想清理一些我从阅读各种文章和教程中无法获得的观点。

After using Homebrew to install Python3, I noticed that it had installed both Python3 and Python3.4. 在使用Homebrew安装Python3之后,我注意到它已经安装了Python3和Python3.4。 I was also a little surprised that there are now three versions of pip on my machine too; 我也有点惊讶的是,我的机器上现在有三个版本的pip; pip, pip3 and pip3.4. pip,pip3和pip3.4。

I created a new virtualenv and told it to use Python3, using the following command: 我创建了一个新的virtualenv并告诉它使用Python3,使用以下命令:

virtualenv -p /usr/local/bin/python3 mysite

I was also surprised that the version of Python that it installed in my VM was 3.4. 我也惊讶于它在我的VM中安装的Python版本是3.4。

  1. Is it safe to have these multiple version of Python and Pip hanging around on my machine? 将这些多个版本的Python和Pip挂在我的机器上是否安全?
  2. Am I right to assume that I should take extra care to use the matching version of pip with Python, for example, pip3.4 with Python3.4? 我是否正确地假设我应该特别注意使用Python的匹配版本的pip,例如pip3.4和Python3.4?
  1. Yes, it is safe. 是的,这是安全的。 Python uses this naming like python3.4, python3.5 etc to differentiate between releases. Python使用python3.4,python3.5等命名来区分版本。 python3 is a symbolic link to the current python3.x version. python3是当前python3.x版本的符号链接。 Pip follows the same convention. Pip遵循相同的惯例。

  2. If you're using python3.4 explicitly, you should be using pip3.4 specifically as well. 如果你明确地使用python3.4 ,你也应该特别使用pip3.4 Otherwise, just use python3 and pip3 . 否则,只需使用python3pip3 For Python 2, you can simply use python (which, unless you installed the Homebrew version as well), will be the system Python), and ditto for pip . 对于Python 2,您可以简单地使用python (除非您安装了Homebrew版本,否则将是系统Python),并且同样适用于pip python2.7 and pip2.7 may also work. python2.7pip2.7也可以工作。

In general, to find out which Python version goes with which pip you're using, try: 一般来说,要找出哪个Python版本与您正在使用的pip有关,请尝试:

pip --version

and you'll see the Python included in the result. 你会看到结果中包含了Python。

No need to worried about if you have multiple version of Python and Pip installed. 如果您安装了多个版本的Python和Pip,则无需担心。 just check your version by writing in terminal : 只需在终端写入来检查您的版本:

$ brew info python $ brew info python

or to check the version of pip write in terminal : 或检查终端中pip写的版本:

$ brew info pip $ brew info pip

and make sure you have updated your both pip and python version (write in terminal $ brew upgrade pip/python) 并确保你已经更新了你的pip和python版本(写在终端$ brew upgrade pip / python)

and other way to install python is go to https://www.python.org/downloads/ and choose as your requirement, there is two version available 2.7.9 & 3.4.3 , after installing python write in terminal $ python -V to check its version :) Hope it will help :) 和其他安装python的方法是去https://www.python.org/downloads/并根据你的要求选择,有两个版本可用2.7.9和3.4.3,在终端安装python写入后$ python -V检查它的版本:)希望它会有所帮助:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM