在 PyCharm 插件项目中编辑 Python 代码

Editing Python code in a PyCharm plugin project

我正在为 PyCharm 编写一个 plugin,当您编辑它时 运行 是您的 Python 代码,并显示所有变量值、循环迭代、和其他州。

它工作得很好,但是编辑我的插件项目中的 Python 代码很尴尬。对内置函数的任何调用都会显示如下检查错误:

Unresolved reference: 'sum'

如果我在我的插件项目中设置一个 Python 解释器,那么所有检查错误都会消失,但我的插件 zip 文件现在包含所有系统 Python 库,我得到这些错误当我尝试从我的插件 运行 Python 脚本时:

Failed to import the site module
Traceback (most recent call last):
 File "/home/don/.IdeaIC2017.1/system/plugins-sandbox/plugins/livepy/classes/site.py", line 78, in <module>
 import os
 File "/home/don/.IdeaIC2017.1/system/plugins-sandbox/plugins/livepy/classes/os/__init__.py", line 7, in <module>
 import subprocess
 File "/home/don/.IdeaIC2017.1/system/plugins-sandbox/plugins/livepy/classes/subprocess.py", line 830, in <module>
 class Popen(object):
 File "/home/don/.IdeaIC2017.1/system/plugins-sandbox/plugins/livepy/classes/subprocess.py", line 1555, in Popen
 def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,
AttributeError: module 'os' has no attribute 'WIFSIGNALED'

如何在我的插件项目中编辑 Python 代码而不出现上面列出的问题?我检查了一下,Python 库没有在项目结构对话框中标记为导出。这是设置 Python 解释器后我的项目文件:

Python 配置现在设置了 sdkName,最后一个 orderEntry 是新的。

在 Project Structure: Modules: Dependencies tab 中,我找到了我需要的设置。如果我将 Python 库的范围设置为 "Provided",那么它不会包含在插件 jar 文件中。