Using PyCharm with GTK3 app

I just installed PyCharm so that I could assess its wonderfulness. However, when I try to run my application, I cannot get past the third line, which is "import gi". I believe that PyCharm is looking in the virtual environment for gi, but of course it resides in a system directory. I googled for a solution, but nothing that I found actually works. I do not want to install GTK in the virtual environment, of course. I am using python 3.8 and Gtk 3.

0
3 comments

You can either create a virtualenv with Inherit global site-packages enabled or add the directory manually to the Interpreter Paths of your virtualenv https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-reloading-interpreter-paths.html

0
Avatar
Permanently deleted user

I created a virtualenv using venv. My application runs fine in the virtual environment. I have

include-system-site-packages = true

in pyvenv.cfg, but setting it false makes no difference. PyCharm still gagged on import gi, so I added

/usr/lib/python3/dist-packages/gi

to the interpreter paths. Now PyCharm no longer complains that it cannot find gi, but I get this error message:

AttributeError: partially initialized module 'enum' has no attribute 'IntFlag' (most likely due to a circular import)

which is coming from /usr/lib/python3.8/re.py.

0

Does your code run when include-system-site-packages is set to False and the Interpreter Paths are unchanged?
How did you install gi?

Have you tried Inherit global site-packages?

0

Please sign in to leave a comment.