I wrote a python script "Script.py" that works when I copy it into the directory I want to run it in. I run this script a lot, so I wanted to add it to .bashrc so I don't have to copy it into every directory I need to run it in.
So the script is in directory:
/home/pythonscripts/Script.py
Now I want to run this script in the directory:
/home/Documents/Test1/
Part of the script is importing a different file (this is unique to each test case). The location of this file is:
/home/Documents/Test1/equations.py
If I start in the "Test1" directory and run "Script.py" I get the following error:
File "/home/python/Script.py", line 115, in <module>
import equations
ImportError: No module named 'equations'
If I place the script into the directory that I'm running this from (/home/Documents/Test1/), there is no error. What I figure is that the script is looking for the equations.py file in the "/home/python" directory, not the local one where I'm running the script from.
My question is how do I tell the script to look in the local directory for the equations.py file in a general way so that I can run Script.py from any directory and have it know to look in the one it's running in for equations.py?