how to add code to python project
I have a project to write plug-ins for gimp. Therefore I need to include python source code from /usr/lib/gimp/2.0. This directory contains several subdirectories with python code, including gimpfu.py. In my plug-in I have to import from this file.
I tried to add this directory as a module dependency, but the gimpfu import is not recognized. When I select this directory I have to Choose Categories of Selected Files, but these are java files, not python.
How do I include these extra python code in my project?
Please sign in to leave a comment.
Hi Chris,
to be able to import your scripts after you've added the parent directory as a module you need to have a module dependency to that module from one where you are importing. Also __init__.py is required in the first module for import to work.
Sorry, didn't work.
I finally got it working when I added /usr/lib/gimp/2.0/python (which contains gimpfu.py) to the project with Modules->Sources->Add Content Root.
Adding this directory as a second new module failed, because IntelliJ tries to write an .iml file in this /usr/lib/... directory (Content root).
Adding it to Dependencies, with or without __init__.py still gave "Unresolved reference".
At least it works now.
Then it's probably a bug:
https://youtrack.jetbrains.com/issue/PY-4270
But, using content roots is also a solution.
What versions of IntelliJ IDEA and the Python plugin do you use? Please attach your idea.log file to PY-4270 (see "Help | Show Log in ...").