title: python crontab and paths
body: <p>I have a Python driver and library scripts that are siblings:</p>
  
  <pre><code>/home/mydir/pythonProjs/
  </code></pre>
  
  <ul>
  <li><p><code>driver.py</code></p></li>
  <li><p><code>lib.py</code></p></li>
  </ul>
  
  <p>In <code>driver.py</code> I have the line:</p>
  
  <p><code>from lib import method1</code></p>
  
  <p>The following is successful from my command line on Linux:</p>
  
  <pre><code>python /home/mydir/pythonProjs/driver.py
  </code></pre>
  
  <p>But when I try the following in crontab:</p>
  
  <p><code>10 1 * * * export PYTHONPATH=~/mydir/pythonProjs; python /home/mydir/pythonProjs/driver.py</code></p>
  
  <p>I get the error:</p>
  
  <pre><code>ImportError: No module named lib.method1
  </code></pre>
  
  <p>I have also attempted changing path setting in my crontab command to the fully-qualified path <code>/home/mydir/pythonProjs</code>, omitting the 'export', and have also attempted writing .sh files (with the necessary #!bin/bash...)</p>
  
  <p>I have one main question and a follow-up question:
  main: What is a best practice way to fix my problem?
  follow-up: What is the philosophy behind cron having different path access than my shell? </p>
  
  <p>Before I get down voted too quickly, I will mention that I have read but have not been successful (or correctly parsed) the following:
  - <a href="https://stackoverflow.com/questions/2229825/where-can-i-set-environment-variables-that-crontab-will-use">Where can I set environment variables that crontab will use?</a>
  - <a href="https://stackoverflow.com/questions/15334052/crontab-issues-running-python">Crontab Issues running Python</a>
  - <a href="http://pythonadventures.wordpress.com/2012/03/31/calling-a-python-script-from-crontab/" rel="nofollow noreferrer">http://pythonadventures.wordpress.com/2012/03/31/calling-a-python-script-from-crontab/</a></p>