我已经安装了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

其他回答

尝试了source activate default_3_9和source conda activate default_3_9

但是conda激活了default_3_9

在桌面或任务栏上创建一个anaconda提示的快捷方式,然后在快捷方式的属性中确保将“Target:”中的最后一个路径修改为你的环境的路径:

C:\Users\BenBouali\Anaconda3\ WILL CHANGE INTO C:\Users\BenBouali\Anaconda3\envs\ tensorflow-gpu

预览

这样你就可以使用这个快捷方式在点击它的时候打开一个特定的环境,你也可以把它添加到你的路径中,现在你就可以从Windows运行框中运行它了,只需要输入快捷方式的名称。

我试图更新蟒蛇,以便使用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快捷方式,但我有我想要的和快速访问。

在Windows上,用下面的代码创建一个批处理文件:

start cmd /k "C:\Anaconda3\Scripts\activate.bat C:\Anaconda3 & activate env"

引号中包含的第一个路径是Anaconda安装中activate.bat文件的路径。系统上的路径可能不同。activate命令后面的名称当然应该是您想要的环境名称。

然后在需要打开Anaconda提示时运行批处理文件。

activate.py是硬编码的,当你计算conda shell生成的shell钩子时,它会将conda activate base\n发送到你的shell配置文件中。zsh钩。

你可以通过以下方式抑制这个硬编码的“自动激活基础”:

conda config --set auto_activate_base false

然后,在~/。zshrc ~ /。Bashrc或任何你的shell配置文件来源,你可以添加以下内容(在conda shell钩子之后)来显式激活你所选择的环境:

conda activate py34