简体   繁体   English

将Anaconda安装到虚拟环境中

[英]Installing Anaconda into a Virtual Environment

I've currently got a working installation of the Enthought Python Distribution on my machine that I don't want to necessarily disrupt, but I'd like to look at moving over to Anaconda from Continuum. 我目前在我的机器上安装了Enthought Python Distribution ,但我不想破坏它,但我想看看从Continuum转移到Anaconda

I can easily install Anaconda into the virtualenv directory I create, but I'm not sure how to tell that virtualenv to use the anaconda-version of Python. 我可以轻松地将Anaconda安装到我创建的virtualenv目录中,但我不知道如何告诉virtualenv使用anaconda-version的Python。 If I was telling my whole system to use it I can alter .bash_profile with something like export PATH="/DIRECTORIES/anaconda/bin:$PATH . Is there a way to do that within a virtualenv? 如果我告诉我的整个系统使用它,我可以改变.bash_profile ,例如export PATH="/DIRECTORIES/anaconda/bin:$PATH 。有没有办法在virtualenv中做到这一点?

I just tested the Anaconde 1.6 installer from http://continuum.io/downloads 我刚从http://continuum.io/downloads测试了Anaconde 1.6安装程序

After downloading, I did: 下载后,我做了:

bash Anaconda-1.6.0-Linux-x86_64.sh

If you take the defaults, you'll end up with a directory anaconda in your home directory, completely separate from your EPD or system Python installation. 如果采用默认值,您最终会在主目录中找到目录anaconda ,与您的EPD或系统Python安装完全分开。

To activate the anaconda installation's default environment, do the following: 要激活anaconda安装的默认环境,请执行以下操作:

source $HOME/anaconda/bin/activate ~/anaconda

All Python commands will now come from the default Anaconda environment in $HOME/anaconda , which is itself a kind of a virtual environment. 所有Python命令现在都来自$HOME/anaconda的默认Anaconda环境,它本身就是一种虚拟环境。 You can create sub-environments with eg conda create -n myenv1 ipython scipy , but this is not necessary. 您可以使用例如conda create -n myenv1 ipython scipy创建子环境,但这不是必需的。

As a side note, you can also use pip (also in $HOME/anaconda/bin ) to install PyPI packages into your Anaconda default environment (it has pip installed by default) or any of the sub-environments (in which case you should first install pip into the sub-environment using conda install -n myenv1 pip ). 作为旁注,您还可以使用pip (也在$HOME/anaconda/bin )将PyPI包安装到您的Anaconda默认环境(默认安装了pip )或任何子环境(在这种情况下,您应该首先使用conda install -n myenv1 pippip安装到子环境中。

It is possible to install parts of Anaconda manually into an existing virtualenv, but using their installer is by far the easiest way to test and use, without affecting any of your existing Python installations. 可以将Anaconda的部分手动安装到现有的virtualenv中,但使用它们的安装程序是迄今为止最简单的测试和使用方式,而不会影响任何现有的Python安装。

创建virtualenv时,请使用-p标志为其提供要使用的Python可执行文件的路径:

virtualenv -p /path/to/python-anaconda-version

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

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