Absolute import in python3 but it cant find my package

Viewed 1332

so I have this directory structure:

/pkg
    /__init__.py
    /script1.py
    /dir1
         /__init__.py
         /file.json
         /dir2
              /__init__.py
              /script2.py

As you can see, I have two script files, script1.py and script2.py, what I'm trying to do is to import script1.py from script2.py, so I did

import pkg.script1

but it is telling me

ModuleNotFoundError: No module named 'pkg'

ports and did

from ... import script1

but I get this error

ValueError: attempted relative import beyond top-level package

Anyone got any idea?

1 Answers
Related