我正在尝试使用importlib导入模块,但得到 没有名为“ configuration”的模块
这是我的目录
我正在尝试运行app.py,它会将配置加载到两个级别
我尝试使用
importlib.import_module( 'configuration' )
configuration_module = importlib.import_module( '.config_loader', package='configuration' )
它无法加载配置
-首页
---配置
---config.py
--- 初始化 .py
--- restful
--- init .py
---应用程序
--- app.py
--- config.py
--- __init__py
Traceback (most recent call last):
File "application/app.py", line 214, in <module>
app = create_app()
File "application/app.py", line 39, in create_app
importlib.import_module( 'configuration' )
File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'configuration'