I have following project structure and i'm using PyCharm.
- Project/
- subproject1/
- main.py
- modules/
- 1.py
- __init__.py
- subproject2/
- main.py
- modules/
- subproject3/
- __init__.py
- file.py
I need in Project/subproject/modules/1.py
a class from Project/subproject3/file.py
. I tried it with from ...subproject3.file import class1
, but then i get the error ValueError: attempted relative import beyond top-level package
. Next i tried the import from subproject3.file import class1
, and that work's, but i don't know why. My working directory in PyCharm is in Project/
but i tried to create a Python application with pyinstaller and that worked also for me and a received no error message. Why does my file 1.py knows from subproject3 and i can import it that way?
Thank you!!