点:处理多个Python版本?
有没有什么办法可以让Python和多个Python版本兼容? 例如,我想用pip来明确地安装事件到我的站点2.5安装或我的站点2.6安装。 
 例如,使用easy_install ,我使用easy_install-2.{5,6} 。 
而且,是的 – 我知道virtualenv,不,这不是解决这个问题的方法。
 从0.8版开始,Pip支持pip-{version} 。 您可以像easy_install-{version}一样使用它: 
 $ pip-2.5 install myfoopackage $ pip-2.6 install otherpackage $ pip-2.7 install mybarpackage 
  编辑 :点子改变了它的模式使用pipVERSION而不是版本1.5中的pip-VERSION 。 如果您有pip >= 1.5您应该使用以下内容: 
 $ pip2.6 install otherpackage $ pip2.7 install mybarpackage 
查看https://github.com/pypa/pip/pull/1053了解更多详情;
参考文献:
  /path/to/python2.{5,6} /path/to/pip install PackageName不起作用? 
 为了在任何没有安装pip的python版本上工作,你需要下载pip,并执行python*version* setup.py install 。 例如python3.3 setup.py install 。 这解决了注释中的导入错误。  (如@ hbdgaf所示) 
在Windows中,您可以通过提及python版本来执行pip模块(您需要确保启动器在您的path上)
 py -3.4 -m pip install pyfora 
 py -2.7 -m pip install pyfora 
或者,您可以直接调用所需的python可执行文件,如下所示:
 /path/to/python.exe -m pip install pyfora 
我默认安装了Python 2.6(Amazon EC2 AMI),但是需要python2.7加上一些外部的包来处理我的应用程序。 假设你已经安装了python2.7和默认的python(在我的情况下是2.6)。 以下是如何为非默认python2.7安装pip和包
为你的python版本安装pip:
 curl -O https://bootstrap.pypa.io/get-pip.py python27 get-pip.py 
使用特定的pip版本来安装软件包:
 pip2.7 install mysql-connector-python --allow-external mysql-connector-python 
它在Windows中这样工作:
- 
我将python文件名python.py和pythonw.exe改名为python3.py pythonw3.py 
- 
然后,我只是在提示符下运行这个命令: python3 -m pip install package
其他答案显示了如何使用2.X和3.X Python中的pip,但没有说明如何处理多个Python分发(例如原始Python和Anaconda Python)的情况 。
我总共有3个Python版本:原始Python 2.7和Python 3.5以及Anaconda Python 3.5。
下面是我如何安装一个包到:
- 
原始的Python 3.5 : /usr/bin/python3 -m pip install python-daemon
- 
原始的Python 2.7 : /usr/bin/python -m pip install python-daemon
- 
Anaconda Python 3.5 : python3 -m pip install python-daemon要么 pip3 install python-daemon更简单,因为Anaconda在用户环境中覆盖了原始的Python二进制文件。 当然,安装在anaconda应该用 conda命令来完成,这只是一个例子。
另外,请确保为特定的python安装了pip。您可能需要手动安装pip。 这在Ubuntu 16.04中可用:
 sudo apt-get install python-pip 
要么
 sudo apt-get install python3-pip 
 所以显然有easy_install 和 pip多个版本。 这似乎是一个大混乱。 无论如何,这是我在Ubuntu 12.10上安装Django for Python 2.7所做的: 
 $ sudo easy_install-2.7 pip Searching for pip Best match: pip 1.1 Adding pip 1.1 to easy-install.pth file Installing pip-2.7 script to /usr/local/bin Using /usr/lib/python2.7/dist-packages Processing dependencies for pip Finished processing dependencies for pip $ sudo pip-2.7 install django Downloading/unpacking django Downloading Django-1.5.1.tar.gz (8.0Mb): 8.0Mb downloaded Running setup.py egg_info for package django warning: no previously-included files matching '__pycache__' found under directory '*' warning: no previously-included files matching '*.py[co]' found under directory '*' Installing collected packages: django Running setup.py install for django changing mode of build/scripts-2.7/django-admin.py from 644 to 755 warning: no previously-included files matching '__pycache__' found under directory '*' warning: no previously-included files matching '*.py[co]' found under directory '*' changing mode of /usr/local/bin/django-admin.py to 755 Successfully installed django Cleaning up... $ python Python 2.7.3 (default, Sep 26 2012, 21:51:14) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import django >>> 
我最近自己碰到这个问题,发现我的Python系统没有得到正确的点子,在我的Linux系统上也有Python 2。
首先你必须确保你已经为你的python版本安装了pip:
对于Python 2:
 sudo apt-get install python-pip 
对于Python 3:
 sudo apt-get install python3-pip 
然后为一个版本的Python或其他版本安装软件包,只需在Python 2中使用以下代码:
 pip install <package> 
或者为Python 3:
 pip3 install <package> 
点也是一个python包。 所以将模块安装到一个特定的python版本的最简单的方法如下
  python2.7 /usr/bin/pip install foo 
要么
 python2.7 -m pip install foo 
从这里: https : //docs.python.org/3/installing/
以下是如何安装在同一时间安装的各种版本的软件包linux,mac,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 python3.5 -m pip install SomePackage # specifically Python 3.5 python3.6 -m pip install SomePackage # specifically Python 3.6 
在Windows上 ,使用Python Python启动器与-m开关结合使用:
 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 
上下文:Archlinux
 行动: 
 安装python2-pip: 
 sudo pacman -S python2-pip 
 你现在有pip2.7: 
 sudo pip2.7 install boto 
 testing(在我的情况下,我需要'博托'): 
 运行以下命令: 
 python2 import boto 
成功:没有错误。
退出: Ctrl + D
例如,如果您将其他版本(例如3.5)设置为默认值,并且希望为python 2.7安装pip:
- 在https://pypi.python.org/pypi/pip(tar )下载pip
- 解压缩tar文件
- cd到文件的目录
- sudo python2.7 setup.py install