I AM NOT TRYING TO IMPORT FROM PARENT FOLDER BUT FROM 2 DIRECTOTIES UP!!
Im am trying to import a file into an script from a relative path. Since Python can only go up 1 directory and not more I need to find the path The code I use is,
from pathlib import Path
import os
path = Path(__file__).parents[2]
p = (os.path.join(path, "Defaults\\"))
from p.Defaults1 import *
I am getting an error ":ModuleNotFoundError: No module named 'p'" when running "from p.Defaults1 import *"
p is the path and not a module. Defaults1 is the file I would like to import.
How can i solve this?
My folder structure is
MAIN FOLDER
sub folder 1
sub folder 2
file_that_has_code_to_import "File_to_import"
File_to_import
As you can see I need to go back UP 2 directories in order to get the file I need