I have a directory structure for my project as
<some_path>/code/project/
/conf
/data
/src/
a/x.py
b/
c/y.py
...
- each of x.py, y.py can run in isolation, so has to append the project path in its own script as
sys.path.append(‘~/code/project’)
-
This becomes unmanageable when your code needs to run on multiple machines on cluster and I end up changing the paths manually 🙁
-
Its a bad design and I want to learn what is the best way to append the project
-
what is the best way to append the project path in this case so that
- I dont write
sys.path.appendin each of the.py file - I can define a master configuration that runs every time a
.py fileruns
- I dont write
Thank you
Add the path to your project to the
PYTHONPATHenvironment variable.See the documentation on the Module Search Path for how exactly this is used.