【问题标题】:Anaconda/MacOS: Change default python versionAnaconda/MacOS:更改默认 python 版本
【发布时间】:2014-07-18 15:10:03
【问题描述】:

当 spyder 崩溃时,我在 osx 10.8 上使用 python 和 anaconda。当我尝试重新启动它时,启动器显示它已卸载。我认为anaconda可能有问题,所以我重新启动了我的计算机,但问题仍然存在。

查看了一下,我注意到python的默认版本已经改变了:

$ python --version
Python 3.4.1 :: Continuum Analytics, Inc.

我尝试使用 Apple 的 defaults write 将其改回,将 python 与 ln -sf 重新链接,只需设置 alias python=python2.7,没有效果。

然后我尝试使用 conda 删除 python3,但 conda remove python3 不会成功。搜索包会产生这样的结果:

$ conda search python
Fetching package metadata: ..
(...)
python                       1.0.1                         0  defaults        
                             (...)
                          .  2.7.5                         2  defaults        
                          .  2.7.5                         3  defaults        
                             (...)
                          *  3.4.1                         0  defaults        

我还查阅了 Continuum 文档,如果我想使用其他版本,他们建议将 2.7 保留为标准版本并使用 Anaconda 环境,但这对我没有帮助。

有人知道如何将默认版本改回 2.7 吗?

(规格为:anaconda 1.7.0、osx 10.8.5、conda 3.5.2)

【问题讨论】:

    标签: python macos anaconda


    【解决方案1】:

    好的,我在 Continuum 邮件列表中发现了类似的问题。

    通过 conda 重新安装 python 解决了这个问题

    $ conda install python=2.7
    Fetching package metadata: ..
    Solving package specifications: .
    Package plan for installation in environment /Users/kadu/anaconda:
    
    The following packages will be downloaded:
    
        package                    |            build
        ---------------------------|-----------------
        conda-3.5.2                |           py27_0         135 KB
        pycosat-0.6.1              |           py27_0          57 KB
        python-2.7.6               |                2        16.5 MB
        pyyaml-3.11                |           py27_0         149 KB
        requests-2.3.0             |           py27_0         564 KB
        ------------------------------------------------------------
                                               Total:        17.4 MB
    
    The following packages will be UN-linked:
    
        package                    |            build
        ---------------------------|-----------------
        conda-3.5.2                |           py34_0
        pycosat-0.6.1              |           py34_0
        python-3.4.1               |                0
        pyyaml-3.11                |           py34_0
        requests-2.3.0             |           py34_0
    
    The following packages will be linked:
    
        package                    |            build
        ---------------------------|-----------------
        conda-3.5.2                |           py27_0   hard-link
        pycosat-0.6.1              |           py27_0   hard-link
        python-2.7.6               |                2   hard-link
        pyyaml-3.11                |           py27_0   hard-link
        requests-2.3.0             |           py27_0   hard-link
    
    Proceed ([y]/n)? 
    

    这也可以用来改变anaconda环境下的默认包:

    $ conda install python=3.4
    Fetching package metadata: ..
    Solving package specifications: .
    Package plan for installation in environment /Users/kadu/anaconda:
    
    The following packages will be UN-linked:
    
        package                    |            build
        ---------------------------|-----------------
        conda-3.5.2                |           py27_0
        pycosat-0.6.1              |           py27_0
        python-2.7.6               |                2
        pyyaml-3.11                |           py27_0
        requests-2.3.0             |           py27_0
    
    The following packages will be linked:
    
        package                    |            build
        ---------------------------|-----------------
        conda-3.5.2                |           py34_0   hard-link
        pycosat-0.6.1              |           py34_0   hard-link
        python-3.4.1               |                0   hard-link
        pyyaml-3.11                |           py34_0   hard-link
        requests-2.3.0             |           py34_0   hard-link
    
    Proceed ([y]/n)? 
    

    但是,这需要手动将构建更改为您使用的任何其他包。我不得不重新安装 spyder,这似乎首先导致了这个错误,并且当我试图在错误的版本下启动它时可能被重新安装了。我没有尝试重新安装的所有其他库在 2.7 下仍然可以正常工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-31
      • 2018-04-10
      • 1970-01-01
      • 2017-03-26
      • 2011-08-16
      • 2015-04-10
      相关资源
      最近更新 更多