'Python3 importing files in different directories
application
├── app
│ └── folder
│ └── file_1.py
│ └── file_2.py
└── app2
└── folder2
└── file_3.py
I created a file_3 and trying to use classes defined in file_1.
I tried to import using the following method but had an issue because file_1 is importing file_2 which then was raising an error.
import sys
sys.path.append('/.../application/app/folder')
import file_1
How can I import file_1 to file_3 and all the files file_1 is depending on.
Solution 1:[1]
I think the answer you are looking for is explained in this article. If I further understand you correctly, file_1is using classes from file_2? So my guess would be, that you also have to import file_2 aswell because the current working directory does not contain a file named file_2.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Hoerbii3 |
