I’m unclear on this: __init__.py
describes the current folder as a module, no?
So if my top level project folder, my_project
, contains file config.py
(my_project/config.py
), then the file in my_project/drivers/sales/customer.py
should be able to import the config.py
module simply by:
import my_project.config
(Errors to:ModuleNotFoundError: No module named 'my_project'
)- Or,
from .. import config
(Errors to:ValueError: attempted relative import beyond top-level package
) - Btw, tried with three dots (...
) with same error. - Or, simply
import config
(Errors to:ModuleNotFoundError: No module named 'config'
)
with the following terminal command:
(env) localhost:/Users/myname/Sites/my_project
$ python drivers/sales/customer.py
How can I accomplish this import?
Versions:
$ python
Python 3.6.2 (default, Jul 17 2017, 16:44:45)