简体   繁体   中英

ImportEror: attempted relative import beyond top-level package

How should I correctly import MyClass.py in SecondClass.py ?

I've tried to do as follows

from ...ConfigFolder.Config import *

but then for some reason i am getting:

ImportError: attempted relative import beyond top-level package

My folder structure:

projectfolder
             |
              - ConfigFolder
                            |-Config.py (inside is MyClass.py)
             |
              - DalFolder
                            |-OtherFold
                                       |-Dal.py (inside SecondClass.py)
             |
              - app.py 

Before you can import from the directories you've created, you'll need to create an __init__.py file in the folder. It can be an empty file.

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