2017-02-28 85 views
1

我有我的系统上的Python 2.7 & 3.5。当我使用sudo,easy_install或pip安装它安装到2.7的包时。为包安装指定Python版本的最简单方法?

我如何告诉点子,须藤,使用easy_install的包安装到3.5?

举例: 这将安装pytest 2.5

pip install -U pytest 

什么是要安装到3.5当量?

+0

python有不同的版本,你可以使用'pip'作为python2和'pip3' for python3 –

回答

2

与指定版本安装任何PIP包的最简单方法锡永是:

对于Python 2.7:

pip install <package_name> 

对于Python 3.x的

pip3 install <package_name> 

这适用于所有的平台,是它的Linux,Windows或Mac,如果你有点子安装包管理器。

0

在Windows上,使用py Python的发射器结合的-m开关:

ES:

py -2 -m pip install SomePackage # default Python 2 

py -2.7 -m pip install SomePackage # specifically Python 2.7 

py -3 -m pip install SomePackage # default Python 3 

py -3.4 -m pip install SomePackage # specifically Python 3.4 

在Linux,Mac OS X和其他POSIX系统,使用:

python2 -m pip install SomePackage # default Python 2 

python2.7 -m pip install SomePackage # specifically Python 2.7 

python3 -m pip install SomePackage # default Python 3 

python3.4 -m pip install SomePackage # specifically Python 3.4 
0

看来你要安装在Mac上使用PIP封装。由于默认的python版本是2.7 for mac,所以默认的pip也会安装到python 2.7。为了安装到自定义版本,你可以这样指定:

python3 -m pip install package 
#or 
python3.5 -m pip install package 

#ie 
python3.5 -m pip install -U pytest 
相关问题