5
├── Codes 
│   ├── GeneralizedInversion.py
│   ├── GeometricalSpreading.py
│   ├── HtoV.py
│   ├── __init__.py
│   ├── interface
│   │   ├── __init__.py
│   │   └── pyqtinter.py
│   ├── rocksiteamplification.py
│   └── TheSoftware.py

within pyqtinter.py i try to import TheSoftware.py using

from .. import TheSoftware

but the error is: ValueError: Attempted relative import in non-package

This link clears why this error is raising: Relative imports for the billionth time

in order to solve this issue two main solutions are using sys.path.append(path) or using -m when executing python code so __name__ isnt set to __main__. it is said that optional attribute __package__ also can be used for solving this issue but i havent found the way to do it. The question is if i set __package__ to Codes.interface then is it possible for python to understand relative imports?

Community
  • 1
  • 1

0 Answers0