There are lots of similar questions, but none of them seem to help me with this. I have the following file structure:
rest_api
__init__.py
utils
__init__.py
config.py
foo
__init__.py
foo.py
I'd like to import the Config
class from config.py
, into foo.py
. I attempt to run:
pipenv run python rest_api/foo/foo.py
I have tried numerous things, including adding the parent folder to PATH and using relative imports, but the import line always fails:
from rest_api.utils.config import Config
I get the following error:
ModuleNotFoundError: No module named 'rest_api'
I should mention that the __init__.py
files are all empty. Not sure if they are neccessary, since I have Python 3.8.2.