简体   繁体   English

如何使用 PyCharm 插件在 IntelliJ IDEA 中配置 Python 解释器?

[英]How do I configure a Python interpreter in IntelliJ IDEA with the PyCharm plugin?

There is a tutorial in the IDEA docs on how to add a Python interpreter in PyCharm, which involves accessing the "Project Interpreter" page. IDEA 文档中有关于如何在 PyCharm 中添加 Python 解释器的教程,其中涉及访问“项目解释器”页面。 Even after installing the Python plugin, I don't see that setting anywhere.即使在安装 Python 插件之后,我也没有在任何地方看到该设置。

Am I missing something obvious?我错过了一些明显的东西吗?

With the Python plugin installed:安装 Python 插件后:

  1. Navigate to File > Project Structure.导航到文件 > 项目结构。
  2. Under the Project menu for Project SDK, select "New" and在 Project SDK 的 Project 菜单下,选择“New”并
  3. Select "Python SDK", then select "Local".选择“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 安装所在的位置。

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 + buttonClasspath选项卡中,单击+按钮添加PYTHONPATH

添加开发工具包

and now the modules will be recognized现在模块将被识别

模块识别

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:为了解决这个问题,我必须这样做:

  1. File -> Project Structure -> Modules File -> Project Structure -> Modules
  2. Click on the Dependencies tab, and click on + and select the python SDK单击Dependencies选项卡,然后单击+并选择 python SDK

    在此处输入图片说明

  3. Click on Apply点击Apply

After that, the warning went away and autocompletion also started working properly在那之后,警告消失了,自动完成也开始正常工作

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在左侧列表中选择Modules
  • Select the Python module in the list of modules在模块列表中选择 Python 模块
  • 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.在右侧,从下拉列表中选择一个现有的 Python SDK,或者单击New...按钮创建一个 virtualenv,或者从系统上的 Python 安装创建一个新的 Python SDK。

Follow these steps:按着这些次序:

  1. Open Setting ( Ctrl + Alt + s )打开设置( Ctrl + Alt + s
  2. Click on plugins点击插件
  3. Find Browse Repositories and click找到浏览存储库并单击
  4. Search for "python"搜索“蟒蛇”
  5. Select Python SDK or pycharm选择 Python SDK 或 pycharm
  6. Restart the IDE重新启动IDE
  7. Go to project structure转到项目结构
  8. Select the python SDK in projects or create a new project with python SDK.在项目中选择python SDK或者用python SDK新建一个项目。

For Pycharm users: 对于Pycharm用户:

FileSettingsProject: MyProjectProject Interpreter 文件设置项目:MyProject⟶ 项目解释器

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何配置 pycharm/intellij idea 来运行 tox 测试 - How to configure pycharm / intellij idea to run tox tests 如何告诉IntelliJ IDEA在哪里找到用于sublime text 2插件开发的python包? - How do I tell IntelliJ IDEA where to find python packages for sublime text 2 plugin development? 在 Windows 上将 python 3.8 降级到 3.7 后,如何在 PyCharm 中配置解释器? - How to configure interpreter in PyCharm after downgrading python 3.8 to 3.7 on windows? 如何使用python检测是否已安装IntelliJ IDEA或PyCharm并获取Windows上exe的路径? - How can I detect if IntelliJ IDEA or PyCharm is installed and get the path to the exe on Windows by using Python? (IntelliJ IDEA)“为模块选择了无效的Python解释器” - (IntelliJ IDEA) “invalid Python interpreter selected for the module” 我的 Pycharm 无法识别 python 3.10,如何配置? - My Pycharm dont recognize python 3.10, how do I configure it? 如何在 OSX 上使用 IntelliJ IDEA 设置 Python 3? - How do I set up Python 3 with IntelliJ IDEA on OSX? IntelliJ Python插件或PyCharm的比较 - Comparison of IntelliJ Python plugin or PyCharm 如何在pycharm中为跨平台项目设置python解释器? - How do I setup the python interpreter in pycharm for a cross-platform project? 我怎么知道在PyCharm中选择哪个HomeBrew Python 3解释器(Mac,Mavericks)? - How do I know which HomeBrew Python 3 Interpreter (Mac, Mavericks) to choose in PyCharm?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM