0

The structure of my project is as follows:

root
    src
        folder1
            file1.py
            file2.py
        folder2
            file1.py
    main.py
    .env

In the main.py file, when trying the following import statement from .src.folder1.file1 import ClassName, I get the following error:

ImportError: attempted relative import with no known parent package

Is there something wrong with my import statement, or should I modify something in my file structure in order to get it to work?

Omar El Atyqy
  • 154
  • 1
  • 1
  • 10
  • I think removing the dot before `src` would make it work, i.e., `from src.folder1.file1 import ClassName`. See this [answer](https://stackoverflow.com/a/14132912/) for more information. – liginity Jun 25 '23 at 07:25
  • It depends on what your `PYTHONPATH` variable contains, and how you run your app. Both will change how imports work. – Lenormju Jun 26 '23 at 09:32

0 Answers0