简体   繁体   中英

Import Module : ModuleNotFoundError: No module named

I have the following folder strucutre. When I run createdb.py, I get the following:

    from wrapper.utils import ymlconfig
ModuleNotFoundError: No module named 'wrapper'
Root
|-- wrapper
|   |-- utils
|   |   `-- ymlutils.py
|   |   `-- __init__.py
|   |-- __init__.py
|   `-- jobs
|-- execute
    `-- createdb.py

I was able to resolve this by

import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
import wrapper
from wrapper.utils import ymlconfig

Thank you all !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM