使用两个不同的 Python 发行版 [英] Using two different Python Distributions

查看:22
本文介绍了使用两个不同的 Python 发行版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前已在我的计算机上下载并使用了 continuum analytics 的 Python 发行版(称为 anaconda).我的问题是我想将 virtualenv 用于烧瓶项目,而 anaconda 会闪烁警告说不支持虚拟环境".有什么办法可以在同一台计算机上运行两个发行版,股票 python 和 anaconda?

I currently have continuum analytics' python distribution (called anaconda) downloaded and in use on my computer. My problem is that I want to use virtualenv for a flask project and anaconda flashes a warning that says "virtual env is not supported". Is there any way i can run two distributions, stock python and anaconda on the same computer?

推荐答案

当然,如果你想单独使用 Anaconda 发行版,你可以设置一个别名来运行那个版本,并且将 stock python 保留为默认值.

Sure, if you want to use the Anaconda distribution separately, you can set up an alias to run that version and leave the stock python as the default.

p>

在您的 .bash_profile 文件中,Anaconda 安装程序可能会放入以下行:

In your .bash_profile file, the Anaconda installer probably put the following line:

export PATH="/path/to/your/anaconda/bin:$PATH"

注释掉这个,并添加一个别名;例如

Comment this out, and add an alias; e.g.

alias pyconda='/path/to/your/anaconda/bin/python'

然后您可以通过在新终端中运行 pyconda 来运行您的 Anaconda python 发行版.

You can then run your Anaconda python distribution by running pyconda in a new terminal.

更新

实际上,当您想使用 anaconda 安装中的所有内容而不是仅使用 python 时,将它放在您的路径中可能会更好(这就是您的 ipython 最初损坏的原因).

It'd actually probably be better to put everything in the anaconda install into your path when you'd like to use it instead of just python (this is why your ipython broke initially).

为此,请设置一个别名,如下所示:

To do this, set up an alias such as the following:

alias anacondainit='export PATH="/path/to/your/anaconda/bin:$PATH"'

然后,您的 anaconda 安装将成为该终端会话中所有内容的默认设置.

Then your anaconda install will be the default for everything in that terminal session.

例如,打开一个新终端后,尝试以下操作:

For instance, after opening up a new terminal, try the following:

amorgan$ python # on a freshly opened terminal, this will load your default distro
Python 2.7.2 |EPD 7.2-1 (32-bit)| (default, Sep  7 2011, 09:16:50)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "packages", "demo" or "enthought" for more information.
>>> exit()

amorgan$ anacondainit #initialize anaconda
amorgan$ python #now when we run python, it will load the anaconda distro
Python 2.7.6 |Anaconda 1.8.0 (x86_64)| (default, Nov 11 2013, 10:49:09)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

要再次使用您的其他发行版,只需加载一个新终端,从而将 anaconda 排除在您的路径之外.

To use your other distribution again, just load up a new terminal, thus getting anaconda out of your path.

这篇关于使用两个不同的 Python 发行版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆