问题:如何在PyCharm中选择Python版本?

我拥有PyCharm 1.5.4,并使用“打开目录”选项在IDE中打开文件夹的内容。

我选择了Python 3.2版(它显示在“外部库”节点下)。

如何选择其他版本的Python(已经安装在计算机上),以便PyCharm改用该版本?

I have PyCharm 1.5.4 and have used the “Open Directory” option to open the contents of a folder in the IDE.

I have Python version 3.2 selected (it shows up under the “External Libraries” node).

How can I select another version of Python (that I already have installed on my machine) so that PyCharm uses that version instead?


回答 0

文件->设置

首选项->项目解释器-> Python解释器

如果未列出,则添加它。

在此处输入图片说明

File -> Settings

Preferences->Project Interpreter->Python Interpreters

If it’s not listed add it.

enter image description here


回答 1

我认为您是说您已经安装了python2和python3,并在Pycharm>设置>项目解释器下添加了对每个版本的引用

我想您要问的是如何在Python 2上运行某些项目,在Python 3上运行某些项目。

如果是这样,您可以在“运行”>“编辑配置”下查看

PyCharm Run>编辑配置

I think you are saying that you have python2 and python3 installed and have added a reference to each version under Pycharm > Settings > Project Interpreter

What I think you are asking is how do you have some projects run with Python 2 and some projects running with Python 3.

If so, you can look under Run > Edit Configurations

PyCharm Run > Edit Configurations


回答 2

PyCharm 2019.1+

状态栏中有一项名为“ 解释器”的新功能(向下滚动一点)。这使得在python解释器之间切换和查看所使用的版本更加容易。

在此处输入图片说明

启用状态栏

如果看不到状态栏,则可以通过运行“查找操作”命令(在Mac上为Ctrl+ Shift+ A+ + A)轻松激活它。然后输入状态栏并选择查看:状态栏以查看它。

在此处输入图片说明

PyCharm 2019.1+

There is a new feature called Interpreter in status bar (scroll down a little bit). This makes switching between python interpreters and seeing which version you’re using easier.

enter image description here

Enable status bar

In case you cannot see the status bar, you can easily activate it by running the Find Action command (Ctrl+Shift+A or + +A on mac). Then type status bar and choose View: Status Bar to see it.

enter image description here


回答 3

在集成了PyCharm的Intellij Ultimate中也可能发生这种情况。问题如上所述,您选择了错误的解释器。

要针对任何给定项目修复此问题的确切方法是转到“ 项目设置项目”,然后调整Project SDK。如果您没有添加Python 3,则可以通过导航到python3二进制文件来添加New Project SDK。这将修复上面列出的错误。“项目设置”的快捷方式是蓝色棋盘式图标。

您还可以将Python 3添加为Python项目的默认解释器。在OSX上,它位于文件中其他设置默认项目结构。您可以在此处设置Project SDK,该SDK现在将应用于每个新项目。它在其他平台上可以有所不同,但仍然相似。

This can also happen in Intellij Ultimate, which has PyCharm integrated. The issue is as diagnosed above, you have the wrong interpreter selected.

The exact method to fix this for any given project is to go to Project SettingsProject and adjust the Project SDK. You can add a New Project SDK if you don’t have Python 3 added by navigating to the python3 binary. This will fix the errors listed above. A shortcut to Project Settings is the blue checkerboard-type icon.

You can also add Python 3 as the default interpreter for Python projects. On OSX this is in File..Other SettingsDefault Project Structure. There you can set the Project SDK which will now apply on each new project. It can be different on other platforms, but still similar.


回答 4

去:

Files -> Settings -> Project -> *"Your Project Name"* -> Project Interpreter

在这里,您可以查看已为python2安装了哪些外部库以及为python3安装了哪些外部库。

根据您的要求选择所需的python版本。

图片

Go to:

Files -> Settings -> Project -> *"Your Project Name"* -> Project Interpreter

There you can see which external libraries you have installed for python2 and which for python3.

Select the required python version according to your requirements.

Image


回答 5

快速回答:

  • File -> Setting
  • project部分的左侧->Project interpreter
  • 选择所需 Project interpreter
  • Apply + OK

[ 注意 ]:

在Pycharm 2018和2017上测试。


Quick Answer:

  • File –> Setting
  • In left side in project section –> Project interpreter
  • Select desired Project interpreter
  • Apply + OK

[NOTE]:

Tested on Pycharm 2018 and 2017.



声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。