ModuleNotFoundError even though the Module is present

I am getting a ModuleNotFoundError for a module that exists. I have a __init__.py and imported sys but I am still getting a ModuleNotFoundError error on my django error.

My file structure:

|-my_app
   |-folder1
     |-__init__.py
     |-calc.py
   |-folder2
     |-__init__.py
     |-test.py

I want to import a function from test.py in calc.py. This is my code:

import sys
from folder2.test import func1, func2

#my code

When I run this, I am getting this error: ModuleNotFoundError: No module named 'folder2.test'

How can I fix this error?

CLICK HERE

Above link might help you.

test is in folder1, so folder2.test will look for folder1\folder2\test.py, which is why the error comes up. Try changing the import to ..folder2.test.

Back to Top