The structure of my project:
project β ββ src β β ββ __init__.py β ββ __main__.py β ββ ... ββ requirements.txt ββ setup.py When testing through the setup.py interpreter, yes, and pylint think that I am in the project folder and expect that in the src files I will add to the imports from src .
When launching __init__.py directly, the opposite is true: from src causes an exception, since I am already in the src folder.
In os looking for how to change the current directory, I did not find it. I would be grateful if you throw an article on structuring projects and the relationship setup.py , __init__.py , __main__.py , etc.
srcneeded, the directory with the application module should have the name of the module, that is, in your case, this is probablyproject- andreymal__init__.pydoesnβt need to be started at all, and since you start it for some reason, it means you are doing something wrong - andreymal__init__.pyrunsmain()inhandler.pyor asks for extra information in exceptional situations. - lisovskeysrctoproject- you getproject/project/__init__.py. Themain()call should be in the__main__.pyfile, and this file should not be launched directly, but with thepython -m projectcommandpython -m projector something like that. Then imports of theimport project(now you haveimport src, you need to rename the directory) will work fine always and everywhere - andreymal