python anaconda - 管理不同 python 版本的模块

python anaconda - manage module for different python versions

我的 Anaconda 中的 mac(2.7 和 3.5.1)中有 2 个版本的 Python。当我每

pip install xxx

它将自动进入 /anaconda/lib/python2.7/site-packages 文件夹。 现在想学aiohttp 装的时候

pip install aiohttp

它会给我错误:

raise RuntimeError("aiohttp requires Python 3.4.1+") RuntimeError: aiohttp requires Python 3.4.1+

---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in

/private/var/folders/c2/3yxfnvc51fng531jz312t00m0000gn/T/pip-build-m_mCpM/aiohttp/

  1. 我该如何解决这个问题?
  2. 管理 AnacondaPython 的 2 个版本的最佳方法是什么?

我刚找到解决方案:

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

来自 python.org.

一般来说,您可以为您正在进行的任何项目创建新环境,使用您需要的任何 python 和包。在这个特定的实例中,如果你想使用需要更高 python 的 aiohttp,我将执行以下操作:

conda create -n py35 python=3.5
source activate py35
pip install aiohttp

这将在您的 py35 环境中安装 aiohttp。

您可以使用 conda 工具来管理您的环境(对于 Python2/Python3)和包。

有关详细信息,请参阅:https://www.continuum.io/content/python-3-support-anaconda