ModuleNotFoundError even though the Module is present


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

My file structure:


I want to import a function from in 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?

Asked By: nb_nb_nb




Above link might help you.

Answered By: Ansh Tyagi

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

Answered By: B Remmelzwaal