python: 安装同一模块的两个版本
python: install two versions of same module
更准确地说,我需要安装两个版本的Pandas。一方面,我在 pandas 0.13 的服务器上编写代码 运行。我工作的所有其他部分,我想要最新的 pandas 和其他模块(目前为 0.16.1)。
这两个项目没有关联,我不会在一个程序中需要两个版本。
有办法吗?
编辑:我在 Windows
下使用 Python 2.7.8 和 Anaconda
最好的方法是 virtualenv。 Virtualenv 是一个创建隔离 Python 环境的工具。
使用pkg_resources
强制版本:
import pkg_resources
pkg_resources.require("YOUR_PACKAGE==VERSION")
import YOUR_PACKAGE
我强烈推荐 miniconda, which is the smaller version of Anaconda。 Conda 是一个包管理器,可以轻松安装 Scipy 和 Numpy 等科学库。要获得它,只需安装 Miniconda 安装程序。
“Miniconda” only contains Python and conda, and is much smaller than
a full Anaconda installer. There are two variants of the installer:
Miniconda is based on Python 2, while Miniconda3 is based on Python 3.
Once Miniconda is installed, you can use the conda command to install
any other packages and create environments (still containing any
version of Python you want). If you have a slow internet connection or
limited disk space, Miniconda is the way to go.
安装Pandas和Numpy等软件包很快,因为很多都已经预编译了。
在OSX上,可以找到最新的Python2版本here,安装如下:
$ bashMiniconda-latest-MacOSX-x86_64.sh -p /usr/local/miniconda -b
$ export PATH=/usr/local/miniconda/bin:$PATH
$ which conda
/usr/local/miniconda/bin/conda
$ conda --version
conda 3.7.0
安装好Miniconda后,您可以使用conda命令安装任何其他包和版本,创建环境等。例如:
$ conda install pandas=0.16.0
...
$ conda create -n py3k anaconda python=3
...
同一个包的两个版本不能同时运行,所以我建议设置一个现有环境的副本,然后安装所需的版本。
conda list
将显示所有已安装的软件包。
更准确地说,我需要安装两个版本的Pandas。一方面,我在 pandas 0.13 的服务器上编写代码 运行。我工作的所有其他部分,我想要最新的 pandas 和其他模块(目前为 0.16.1)。
这两个项目没有关联,我不会在一个程序中需要两个版本。
有办法吗?
编辑:我在 Windows
下使用 Python 2.7.8 和 Anaconda最好的方法是 virtualenv。 Virtualenv 是一个创建隔离 Python 环境的工具。
使用pkg_resources
强制版本:
import pkg_resources
pkg_resources.require("YOUR_PACKAGE==VERSION")
import YOUR_PACKAGE
我强烈推荐 miniconda, which is the smaller version of Anaconda。 Conda 是一个包管理器,可以轻松安装 Scipy 和 Numpy 等科学库。要获得它,只需安装 Miniconda 安装程序。
“Miniconda” only contains Python and conda, and is much smaller than a full Anaconda installer. There are two variants of the installer: Miniconda is based on Python 2, while Miniconda3 is based on Python 3. Once Miniconda is installed, you can use the conda command to install any other packages and create environments (still containing any version of Python you want). If you have a slow internet connection or limited disk space, Miniconda is the way to go.
安装Pandas和Numpy等软件包很快,因为很多都已经预编译了。
在OSX上,可以找到最新的Python2版本here,安装如下:
$ bashMiniconda-latest-MacOSX-x86_64.sh -p /usr/local/miniconda -b
$ export PATH=/usr/local/miniconda/bin:$PATH
$ which conda
/usr/local/miniconda/bin/conda
$ conda --version
conda 3.7.0
安装好Miniconda后,您可以使用conda命令安装任何其他包和版本,创建环境等。例如:
$ conda install pandas=0.16.0
...
$ conda create -n py3k anaconda python=3
...
同一个包的两个版本不能同时运行,所以我建议设置一个现有环境的副本,然后安装所需的版本。
conda list
将显示所有已安装的软件包。