简体   繁体   中英

Fail to import a Module: ModuleNotFoundError: No module named 'folder'

Am try to get my head around python package and module, in a structure below in serengeti.py i import arusha module by doing from ubongo.arusha import Lake (lake is a method in arusha module) i get an error "ModuleNotFoundError" do i need to add to PYTHONPATH. i dont know what am doing wrong any help you can provide on my learning journey i would appreciate

ubongo
      |
       __init__.py
      |
       arusha.py
      |
      manyara 
             |
             __init__.py
             |
              serengeti.py

you need the ubongo parent to be the working directory or to be on PYTHOPATH.

The former option is the better practice as messing with PYTHONPATH can make problems.

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