Skip to content

Category: system

Best way to setup PYTHONPATH for crontab

There are many suggestions on this.

Add PYTHONPATH at the end of the ~/.bash_profile or ~/.bash_login files. If they do not exist, add it to ~/.bash_profile as suggested by this StackOverflow post.

export PYTHONPATH="${PYTHONPATH}:/home/path/to/your/python/package/"

But this will add the package to the current user’s PYTHONPATH. To ensure crontab gets it right away. add this line to the top of crontab file, BEFORE crontab tries to execute any script of that package

PYTHONPATH/home/path/to/your/python/package
Leave a Comment