简体   繁体   中英

Editing Python code in a PyCharm plugin project

I'm writing a plugin for PyCharm that runs your Python code while you edit it, and displays all the variable values, looping iterations, and other state.

It's working pretty well, but it's awkward to edit the Python code that's part of my plugin project. Any calls to built-in functions show an inspection error like this:

Unresolved reference: 'sum'

If I set a Python interpreter in my plugin project, then all the inspection errors go away, but my plugin zip file now includes all the system Python libraries, and I get these errors when I try to run Python scripts from my plugin:

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'

How can I edit the Python code in my plugin project without the problems I listed above? I checked, and the Python library is not marked for export in the project structure dialog. Here is my project file after setting the Python interpreter:

The Python configuration now has its sdkName set, and the last orderEntry is new.

In the Project Structure: Modules: Dependencies tab , I found the setting I needed. If I set the Python library's scope to "Provided", then it doesn't get included in the plugin jar file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM