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

source activate py34
ipython

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


当前回答

我在使用anaconda安装图书馆时得到了这个。我的版本来自Python 3。*到2.7,我的很多东西停止工作。 我发现最好的解决方案是先看看最新的版本:

conda search python

然后更新到你想要的版本:

conda install python=3.*.*

来源:http://chris35wills.github.io/conda_python_version/

其他有用的命令:

conda info
python --version

其他回答

永久不变的

conda install python={version}

临时改变

查看环境

在终端窗口或Anconda提示符上运行conda info——envs

如果它没有显示要安装的环境

执行conda create -n py36 python=3.6 anaconda for python 3.6更改版本

激活一个环境(使用Anaconda提示符)

运行activate envnme envnme,你可以通过命令conda info——envs找到envnme,作为一个例子,当你运行conda info——envs it show时

base * C:\Users\DulangaHeshan\Anaconda3 py36 C:\Users\ DulangaHeshan \ Anaconda3 \ env \ py36

然后执行activate py36

执行python——version命令查看

在Windows中,在激活另一个环境之前禁用一个环境是一种良好的实践。 https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html?highlight=deactivate%20environment

我试图更新蟒蛇,以便使用Python 3.10.4和Spyder 5.3.2。实际上,我想在Spyder控制台中设置Pycharm使用的Python解释器,但它需要最新的Spyder版本。我没有尝试所有可能的解决方案(它等待我使用窗口批处理和修改这里给出的路径解决方案),但是:

Since I couldn't update the Anaconda base due to the well-known error on the "Solving environment". Then Python and Spyder remain the same. Creating a new env allows to get the last Python and then his newest Spyder version but it doesn't actualize the Anaconda shortcuts and even the Anaconda navigator if you set it to this new env still has some inconsistencies like keeping the older Spyder version in his menu. Besides, on point 2, changing the shortcuts target path doesn't work for me. Finally, I create a new shortcut of the Spyder file from the Scripts folder inside the environment directory ( C:\Users<userName>>\Anaconda3\envs<EnvName>\Scripts )

我不能使用默认的Anaconda快捷方式,但我有我想要的和快速访问。

在Linux下,通过修改~/有一种更简单的方法来设置默认环境。bashc或~/.bash_profile 最后你会发现

# added by Anaconda 2.1.0 installer
export PATH="~/anaconda/bin:$PATH"

将其替换为

# set python3 as default
export PATH="~/anaconda/envs/python3/bin:$PATH"

这就是它的全部。

正确答案(截至2018年12月)是……你不能。升级conda install python=3.6可能会工作,但如果你有必要的包,但不能卸载,则可能不会。

Anaconda uses a default environment named base and you cannot create a new (e.g. python 3.6) environment with the same name. This is intentional. If you want your base Anaconda to be python 3.6, the right way to do this is to install Anaconda for python 3.6. As a package manager, the goal of Anaconda is to make different environments encapsulated, hence why you must source activate into them and why you can't just quietly switch the base package at will as this could lead to many issues on production systems.

只要在加载终端/shell时激活py34环境即可。

如果您使用Bash,请输入以下语句:

conda activate py34

在你的.bash_profile(或.bashrc)中:

$ echo 'conda activate py34' >> ~/.bash_profile

每次运行新终端时,都会加载conda环境py34。