Add a directory to Python path
In order to use your own python modules ubiquitously you need to add the containing directory MODULES_DIR to the python path.
There are two ways to do it:
- Append at run-time
-
Use sys.path.append($MODULES_DIR).
You should note that:- the path will dissapear as soon as the execution of your new module finish, and
- if you refactor your library you will have two change $MODULES_DIR in every file containing it.
- Append to the PYTHONPATH environment variable
-
Add export PYTHONPATH=$PYTHONPATH:$MODULES_DIR to your ~/.bashrc file.
Run source ~/.bashrc to reload the file without re-logging.