Running a project with absolute imports

Until now I never had any issue with pycharm, but recently I discovered photini (a open source photo metadata editor) written in python and I wanted to collaborate (project here https://github.com/jim-easterbrook/Photini), that builds normally out of pycharm but fails inside.

The folder structure is the following (only problematic files here):

src
photini
editor.py
gi.py
..

To run the project I should be able to just run editor.py and start, but it doesn't work.

The most problematic bits are:

#in editor.py
from
photini.gi import gi_version

And also in gi.py:

try:
import pgi
pgi.install_as_gi()
using_pgi = True
except ImportError:
using_pgi = False
import gi

The issue seems to be that there's a library called gi already on the system, and according to photini's author the problem i because of the way pycharm is importing this libraries, quoting:

The Photini module photini.gi imports the PyGObject module gi. If you
allow "relative" imports, then Python might try to find
gi.require_version in photini.gi instead of gi. Absolute imports are the
default when running Python normally so this isn't a problem. Does
running in an IDE allow relative imports? Is this an option that can be
turned off?

So far the only thing I could check was to change src as 'Sources Root', but it doesn't make a difference, and I'm quite lost.

Could anyone spot the issue here? Any help appreciated

Please sign in to leave a comment.