I'm using python 2.7 in a linux environment and I'm having trouble importing a .py file under certain conditions. My directory-tree is as follows:
/mainFolder
executable.py
/Folder
input_file.py
executable.py
imports input_file.py
with the line __import__('input_file')
When I am in the folder mainFolder/Folder
and I run ../executable.py
I get the output: ImportError: No module named input_file
And when I move input_file.py
into mainFolder
it works. From looking at it I'm under the impression that input_file.py
isn't in python's path and I know how to fix that.
I'm under the impression though that it should work as is, as this is code that is from a github repository and presumably works on the author's computer, but this is apparently not the case.
Is there a setting I can change so I don't have to do something like sys.path.append(0,'mainFolder/Folder')
?