如何使用 PyCharm 插件在 IntelliJ IDEA 中配置 Python 解释器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24769117/
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 do I configure a Python interpreter in IntelliJ IDEA with the PyCharm plugin?
提问by kousen
There is a tutorial in the IDEA docs on how to add a Python interpreter in PyCharm, which involves accessing the "Project Interpreter" page. Even after installing the Python plugin, I don't see that setting anywhere.
IDEA 文档中有关于如何在 PyCharm 中添加 Python 解释器的教程,其中涉及访问“项目解释器”页面。即使在安装 Python 插件之后,我也没有在任何地方看到该设置。
Am I missing something obvious?
我错过了一些明显的东西吗?
回答by Makoto
With the Python plugin installed:
安装 Python 插件后:
- Navigate to File > Project Structure.
- Under the Project menu for Project SDK, select "New" and
- Select "Python SDK", then select "Local".
- 导航到文件 > 项目结构。
- 在 Project SDK 的 Project 菜单下,选择“New”并
- 选择“Python SDK”,然后选择“本地”。
Provided you have a Python SDK installed, the flow should be natural from there - navigate to the location your Python installation lives.
如果您安装了 Python SDK,那么流程应该很自然——导航到您的 Python 安装所在的位置。
回答by Prakash
Follow these steps:
按着这些次序:
- Open Setting (Ctrl+ Alt+ s)
- Click on plugins
- Find Browse Repositories and click
- Search for "python"
- Select Python SDK or pycharm
- Restart the IDE
- Go to project structure
- Select the python SDK in projects or create a new project with python SDK.
- 打开设置 ( Ctrl+ Alt+ s)
- 点击插件
- 找到浏览存储库并单击
- 搜索“蟒蛇”
- 选择 Python SDK 或 pycharm
- 重新启动IDE
- 转到项目结构
- 在项目中选择python SDK或者用python SDK新建一个项目。
回答by Menelaos Kotsollaris
For Pycharm users:
对于 Pycharm 用户:
File? Settings? Project: MyProject? Project Interpreter
File? Settings? Project: MyProject?Project Interpreter
回答by Tarun Lalwani
So here is a simple project, where I have used Selenium
and added that using external path
所以这是一个简单的项目,我在其中使用Selenium
并添加了使用外部路径
Now you need to open Project Structure
and go to SDK
Section
现在您需要打开Project Structure
并转到SDK
部分
Now Select your project's virtual environment. In the Classpath
tab add the PYTHONPATH
by clicking +
button
现在选择您项目的虚拟环境。在Classpath
选项卡中PYTHONPATH
通过单击+
按钮添加
and now the modules will be recognized
现在模块将被识别
回答by Zoltán
If you have multiple modules in your project, with different languages, you can set the interpreter in the following way:
如果您的项目中有多个模块,使用不同的语言,您可以通过以下方式设置解释器:
File -> Project Structure...
- Select
Modules
in the list on the left - Select the Python module in the list of modules
- On the right-hand side, either choose an existing Python SDK from the dropdown list, or click on the
New...
button to create either a virtualenv, or create a new Python SDK from a Python installation on your system.
File -> Project Structure...
Modules
在左侧列表中选择- 在模块列表中选择 Python 模块
- 在右侧,从下拉列表中选择现有的 Python SDK,或单击
New...
按钮创建 virtualenv,或从系统上的 Python 安装创建新的 Python SDK。
回答by Junaid
I was getting the error (IntelliJ on Ubuntu 18.04) while python SDK was configured.
配置 python SDK 时出现错误(Ubuntu 18.04 上的 IntelliJ)。
To fix that, I had to do this:
为了解决这个问题,我必须这样做:
File
->Project Structure
->Modules
Click on the
Dependencies
tab, and click on+
and select the python SDKClick on
Apply
After that, the warning went away and autocompletion also started working properly
在那之后,警告消失了,自动完成也开始正常工作