【问题标题】:Changing Default Python env.(from 2.7 to 3.3) in Anaconda on Mac OS 10.8在 Mac OS 10.8 上的 Anaconda 中更改默认 Python 环境(从 2.7 到 3.3)
【发布时间】:2014-02-10 19:15:52
【问题描述】:

我为 Mac 安装了 Anaconda 发行版。我有 Mac OSX 10.8(山狮)。我不经常使用 Anaconda 的问题是因为它使用的默认 Python 是 2.7,而我使用 3.3 或至少更喜欢使用它。

我真的很喜欢 Anaconda 的 Spyder IDE。有没有办法让 Anaconda 上的默认环境更改为 3.3 而不是 2.7,以便 Spyder 和 iPython 都使用 3.3 默认值?

我从 Anaconda 网站看到以下帮助:

$ conda create -n py3k python=3 anaconda

Here python=3 and anaconda are package specifications, and it is the job of the SAT solver inside conda to find a consistent set of packages which satisfies these requirements. As the root environment uses Python 2, we had to specify the major version explicitly.

After adding the binary directory of the newly created environment to the PATH environment variable, which may be done using

$ source activate py3k

我的问题是我已经使用 Homebrew 单独安装了 Python 3.3 和相关的科学 Python 包,如 Pandas、numpy、scipy、scikit-learn 等,这样它就不会与我的 Mac OS 默认 Python 2.7 冲突。那么现在如果我在 Mac Terminal 中运行上述 Conda 命令,它会干扰我使用 Homebrew 安装的其他 Python 包吗?还是会自动安装/升级 Anaconda 库中的 python 和其他包,而不干扰 Homebrew 安装的 Python 或 Mac OS 默认的 Python?

请指教。

【问题讨论】:

  • 只要确保source activate你想要的python,你应该没问题。你总是可以通过which python(或which condawhich pip)在终端上判断哪个python是“活动的”。
  • @TomAugspurger 如何source activate特定的python版本?
  • conda 环境将有一个 bin 文件夹,其中包含一个 activate 脚本。所以你想要source <ENV NAME>/bin/activate

标签: python-3.x pandas osx-mountain-lion anaconda


【解决方案1】:

不,Homebrew 和 Anaconda Python 将保持完全独立。只要确保您没有设置PYTHONPATH,这会导致这不正确。

另外,你应该知道 Spyder 在 Anaconda 中还不能用于 Python 3,因为 PySide 还没有为 Python 3 构建。

【讨论】:

  • 更新:Spyder 已经可用于 Anaconda 中的 Python 3。我在 3.4 中使用它
【解决方案2】:

我已经用 python 2.7 安装了 Anaconda,但即使在添加了 python3 之后:

conda create --name Py3 python=3

spyder继续调用python2.7

使用 spyder 和 python=3 创建环境对我有用:

conda create --name SpyPy3 python=3 spyder

【讨论】:

    猜你喜欢
    • 2015-04-10
    • 2016-06-05
    • 2018-01-22
    • 1970-01-01
    • 1970-01-01
    • 2019-03-09
    • 2020-12-01
    • 1970-01-01
    相关资源
    最近更新 更多