This is my folder structure:
src
file1.py
file2.py
tests
test1.py
#file1.py
from file2 import module2
modules = 'module1' + module2
#file2.py
module2 = 'module2'
#test1.py
import sys
sys.path.append('..')
from src.file1 import modules
print(modules)
I cannot "import modules from src.file1" because ModuleNotFoundError: No module named ‘file2’.
How can I import modules from another folder where the module that I am importing also imports modules from other files?
2
Answers
with the following launch config I have it running
and a change to
test1.py
put your directories (src and test) in a directory (path_problem)
change test1.py
create a file called init.py and another called run.py in the path_problem diectory
You should see the output of the print statement in test1.py