使用 Python 的多个版本启动 Spyder

Launching Spyder with multiple versions of Python

我有 python 2.7 作为我的基础。我用 python 3.7.

创建了一个环境

conda create -n py3 python=3.7

在蟒蛇提示中。 现在我已经激活了我的 python 3.7.

conda activate py3 or activate py3

现在我用

检查了我的python版本
python --version

其状态为 python 3.7.7

conda run spyder

现在 spyder 已启动,但它仍在 python 2.7 中打开。

我想使用 PyTorch,但还需要 python 2.7,而 PyTorch 不适合与 python 2.7 一起使用。我需要在 python 3.7 中使用 PyTorch,我还需要在单个系统中使用 python 2.7。我该怎么做?环境设置还可以,但spyder的启动是我真正的问题。

在 Anaconda 提示符中键入以下内容:

conda create --name py2 Python=2.7

它将创建一个虚拟环境 Python 2.7

activate py2

对于运行版本为2的Python spyder,命令必须是

conda run spyder

要停用虚拟环境:

conda deactivate

同样适用于虚拟环境 Python 3

conda create --name py3 Python=3.7
activate py3
conda run spyder
conda deactivate