将 Anaconda 安装到虚拟环境中

时间:2023-03-03
本文介绍了将 Anaconda 安装到虚拟环境中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前已经安装了 Enthought Python Distribution在我不想破坏的机器上,但我想看看转移到 Anaconda 来自 Continuum.

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.

我可以轻松地将 Anaconda 安装到我创建的 virtualenv 目录中,但我不确定如何告诉 virtualenv 使用 Python 的 anaconda 版本.如果我告诉我的整个系统使用它,我可以用 export PATH="/DIRECTORIES/anaconda/bin:$PATH 之类的东西来更改 .bash_profile.有没有办法在 virtualenv 中执行此操作?

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. 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?

推荐答案

我刚刚从 http://测试了 Anaconde 1.6 安装程序continuum.io/downloads

下载后,我做了:

bash Anaconda-1.6.0-Linux-x86_64.sh

如果您采用默认设置,您最终会在您的主目录中获得一个目录 anaconda,与您的 EPD 或系统 Python 安装完全分开.

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 安装的默认环境,请执行以下操作:

To activate the anaconda installation's default environment, do the following:

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

所有 Python 命令现在都来自 $HOME/anaconda 中的默认 Anaconda 环境,它本身就是一种虚拟环境.您可以使用例如创建子环境conda create -n myenv1 ipython scipy,但这不是必须的.

All Python commands will now come from the default Anaconda environment in $HOME/anaconda, which is itself a kind of a virtual environment. You can create sub-environments with e.g. conda create -n myenv1 ipython scipy, but this is not necessary.

附带说明,您还可以使用 pip(也在 $HOME/anaconda/bin 中)将 PyPI 包安装到您的 Anaconda 默认环境中(它具有 pip 默认安装)或任何子环境(在这种情况下,您应该首先使用 conda install -n myenv1 pip<将 pip 安装到子环境中/code>).

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).

可以将部分 Anaconda 手动安装到现有的 virtualenv 中,但使用它们的安装程序是迄今为止测试和使用的最简单方法,不会影响您现有的任何 Python 安装.

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 安装到虚拟环境中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!