如何更改默认的Anaconda python环境 [英] How to change default Anaconda python environment

查看:1328
本文介绍了如何更改默认的Anaconda python环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了Anaconda,并创建了两个额外的环境:py3k(具有Python 3.3)和py34(具有Python 3.4).除此之外,我还有一个默认环境"root",该环境由Anaconda安装程序默认创建,并包含Python 2.7.最后一个是默认值,每当我从终端启动"ipython"时,它就会给我2.7版本.为了使用Python 3.4,我需要发出命令(在外壳中)

I've installed Anaconda and created two extra environments: py3k (which holds Python 3.3) and py34 (which holds Python 3.4). Besides those, I have a default environment named 'root' which the Anaconda installer created by default and which holds Python 2.7. This last one is the default, whenever I launch 'ipython' from the terminal it gives me version 2.7. In order to work with Python 3.4, I need to issue the commands (in the shell)

source activate py34
ipython

将默认环境更改为Python 3.4.这很好用,但是很烦人,因为我大部分时间都在使用Python 3.4而不是Python 2.7(我出于教学目的持有这是一个很长的故事).无论如何,我想知道如何将默认环境更改为Python 3.4,但要记住我不想从头开始重新安装所有内容.

which change the default environment to Python 3.4. This works fine, but it's annoying since most of the time I work on Python 3.4, instead of Python 2.7 (which I hold for teaching purposes, it's a rather long story). Anyway, I'll like to know how to change the default environment to Python 3.4, bearing in mind that I don't want to reinstall everything from scratch.

推荐答案

如果只想更改为其他环境,请使用

If you just want to change to another environment, use

source activate environment-name

(您可以使用`conda create创建environment-name)

(you can create environment-name with `conda create)

通常最好只创建新环境.但是,如果您确实想在默认环境中更改Python版本,则可以执行以下操作:

Typically it's best to just create new environments. However, if you really want to change the Python version in the default environment, you can do so as follows:

首先,通过运行确保您拥有最新版本的conda

First, make sure you have the latest version of conda by running

conda update conda

然后运行

conda install python=3.5

这将尝试将根环境中的所有软件包更新为Python 3版本.如果不可能(例如,因为某些软件包不是为Python 3.5构建的),则会向您显示一条错误消息,指出哪个软件包导致了此问题.

This will attempt to update all your packages in your root environment to Python 3 versions. If it is not possible (e.g., because some package is not built for Python 3.5), it will give you an error message indicating which package(s) caused the issue.

如果您使用pip安装了软件包,则必须重新安装它们.

If you installed packages with pip, you'll have to reinstall them.

这篇关于如何更改默认的Anaconda python环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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