dir1\
__init__.py
config.py
dir2\
__init__.py
module1.py
In order to protect sensitive config settings, I have a file config.py in let's say dir1. I have dir2 that has the main Python files.
I want all the modules in dir2 to be able to access config.py. So I thought to import it once inside __init__.py that is inside dir2.
How do I do this? I tried putting this inside __init__.py in dir2:
# __init__.py in dir2
import os
import sys
config_dir = os.path.join(os.environ['userprofile'],'Path','To','dir1')
sys.path.append(config_dir)
from dir1 import config
I put this in module1.py
# module1.py
from config import USERS
but when I run module1 I get:
ModuleNotFoundError: No module named 'config'.