2 Comments

For the reader: If you think importing can be confusing try to import from a sister package in your own project.

After hours of googling this was the best answer I found:

https://stackoverflow.com/a/50193944/14198656

TL:DR: Install your own package in editable mode:

pip install -e . (note the dot. you should be in a venv in the root directory of your project). Trust me, although I was hesitant for a long time this turned out to be the easiest solution by far.

Expand full comment

Note that only pip has editable mode, that will not work with other systems, like anaconda.

I would rather recommend to always run everything from the root of the project, and make sure PYTHONPATH is setup accordingly to contain the root as well.

Unfortunatly, setting up PYTHONPATH is not the most intuitive things to do for most people. I wrote an article on it, but let's be real, a lot of dev have no idea how to use env vars.

Expand full comment