I have a folder structure of Python files that looks like so:
folder w space
├── folder1
│ └── subfolder1
│ └── file_1.py *is main*
└── folder2
└── folder w space2
└── file_2.py
└── __init__.py
I'm needing to have file_1.py
(file that has main) import file_2.py
as a package. Notice that file_2.py
, in relation to file_1.py
, is 3 directories up and then 3 directories down. I would, in theory, write the relative import as so:
from ...folder2 import folder w space2.file2
However this is not valid due to the spacing in the subfolder. An absolute import is even worse because the base folder contains spaces too:
import folder w space.folder2.folder w space2.file2
With this, how can I import file_2.py
as a module without:
- Renaming the folders (I don't own them so I can't even if I wanted to)
- Without using
sys.path.append()
(does not work in our production env) - Moving
file_2.py
(for organization must stay where it is) - Hopefully not install any further libraries (isn't absolutely necessary but it would be a whole process for me to add new libraries to our production env)
Any help would be immensely appreciated!