如何在 anaconda spyder 中更改 python 版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43592879/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change python version in anaconda spyder
提问by Jeevan
I am using 3.6 Python version in anaconda spyder on my mac. But I want to change it to Python 2.7.
我在 Mac 上的 anaconda spyder 中使用 3.6 Python 版本。但我想将其更改为 Python 2.7。
Can any one tell me how to do that?
谁能告诉我怎么做?
回答by MSeifert
You can open the preferences (multiple options):
您可以打开首选项(多个选项):
- keyboard shortcut Ctrl+ Alt+ Shift+ P
Tools
->Preferences
- 键盘快捷键Ctrl+ Alt+ Shift+P
Tools
->Preferences
And depending on the Spyder version you can change the interpreter in the Python interpreter
section (Spyder 3.x):
根据 Spyder 版本,您可以在Python interpreter
(Spyder 3.x) 部分更改解释器:
or in the advanced Console
section (Spyder 2.x):
或在高级Console
部分(Spyder 2.x):
回答by Hossein Rahimi
First, you have to run below codes in Anaconda prompt
,
首先,您必须在以下代码中运行Anaconda prompt
,
conda create -n py27 python=2.7 #for version 2.7
activate py27
conda create -n py36 python=3.6 #for version 3.6
activate py36
Then, you have to open Anaconda navigator
and,
The button might say "install" instead of Launch. After the installation, which takes a few moments, It will be ready to launch.
然后,您必须打开Anaconda navigator
并且,
该按钮可能会说“安装”而不是“启动”。安装后,这需要一些时间,它将准备启动。
Thank you, @cloudscomputes and @Francisco Camargo.
谢谢@cloudscomputes 和@Francisco Camargo。
回答by Dan
If you want to keep python 3, you can follow these directionsto create a python 2.7 environment, called py27.
如果你想保留 python 3,你可以按照这些说明创建一个 python 2.7 环境,称为 py27。
Then you just need to activate py27:
然后你只需要激活py27:
$ conda activate py27
Then you can install spyder on this environment, e.g.:
然后你可以在这个环境中安装 spyder,例如:
$ conda install spyder
Then you can start spyder from the command line or navigate to 2.7 version of spyder.exe below the envs directory (e.g. C:\ProgramData\Anaconda3\envs\py27\Scripts)
然后你可以从命令行启动 spyder 或导航到 envs 目录(例如 C:\ProgramData\Anaconda3\envs\py27\Scripts)下的 spyder.exe 2.7 版本
回答by Francisco Camargo
You can launch the correct version of Spyder by launching from Ananconda's Navigator. From the dropdown, switch to your desired environment and then press the launch Spyder button. You should be able to check the results right away.
您可以通过从Ananconda 的 Navigator启动来启动正确版本的 Spyder 。从下拉菜单中,切换到您想要的环境,然后按下启动 Spyder 按钮。您应该能够立即检查结果。
回答by cmpgamer
In Preferences, select Python Interpreter
在首选项中,选择 Python 解释器
Under Python Interpreter, change from "Default" to "Use the following Python interpreter"
在 Python 解释器下,从“默认”更改为“使用以下 Python 解释器”
The path there should be the default Python executable. Find your Python 2.7 executable and use that.
路径应该是默认的 Python 可执行文件。找到您的 Python 2.7 可执行文件并使用它。
回答by Han
Set python3 as a main version in the terminal: ln -sf python3 /usr/bin/python
Install pip3: apt-get install python3-pip
Update spyder: pip install -U spyder
在终端中将python3设置为主版本:ln -sf python3 /usr/bin/python
安装 pip3:apt-get install python3-pip
更新 spyder:pip install -U spyder
Enjoy
享受
回答by cloudscomputes
If you are using anaconda to go into python environment you should have build up different environment for different python version
如果你使用 anaconda 进入 python 环境,你应该为不同的 python 版本建立不同的环境
The following scripts may help you build up a new environment(running in anaconda prompt)
以下脚本可以帮助您建立一个新环境(在 anaconda 提示符下运行)
conda create -n py27 python=2.7 #for version 2.7
activate py27
conda create -n py36 python=3.6 #for version 3.6
activate py36
you may leave the environment back to your global env by typing
deactivate py27
or
deactivate py36
and then you can either switch to different environment using your anaconda UI with @Francisco Camargo 's answer
然后你可以使用 @Francisco Camargo 的答案使用 anaconda UI 切换到不同的环境
or you can stick to anaconda prompt using @Dan 's answer
或者您可以使用 @Dan 的回答坚持使用 anaconda 提示