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

2024-09-30 16:31:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在为PyCharm编写一个plugin,它在您编辑Python代码时运行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是新的


Tags: 项目代码inpy插件homelineplugins