ImportError only for crontab job?
<p>So I wrote a nifty automation script that does some of my work for me via the jira module + handy dandy logic.  It runs perfectly from the command line via:</p>

<pre><code>me@local] ~/Documents/auto_updater &gt; python /Users/me/Documents/auto_updater/jira_updater.py 
Missing info starting
  checking out:  ES-20157
    No array outage
    Already has sev1_missing_outage label.
***snip***
</code></pre>

<p>It also works just fine ran with fullpath without the python call:</p>

<pre><code>me@local] ~/Documents/auto_updater &gt; /Users/me/Documents/auto_updater/jira_updater.py 
Missing info starting
  checking out:  ES-20157
    No array outage
    Already has sev1_missing_outage label.
</code></pre>

<p>Now - assuming that it working means life is good, I decided to set it up on a crontab for 30 min periods, and I'm getting spam failures every time where it can't seem to find the jira module:</p>

<pre><code>From me@me-mbp  Mon Oct 17 19:30:04 2016
Return-Path: &lt;me@me-mbp&gt;
X-Original-To: me
Delivered-To: me@me-mbp
Received: by me-mbp (Postfix, from userid 502)
    id 514D0203328A; Mon, 17 Oct 2016 19:30:00 -0600 (MDT)
From: me@me-mbp (Cron Daemon)
To: me@me-mbp
Subject: Cron &lt;me@local&gt; python /Users/me/Documents/auto_updater/jira_updater.py &gt;&gt; /Users/me/Documents/auto_updater/updated_log.txt
X-Cron-Env: &lt;SHELL=/bin/sh&gt;
X-Cron-Env: &lt;PATH=/usr/bin:/bin&gt;
X-Cron-Env: &lt;LOGNAME=me&gt;
X-Cron-Env: &lt;USER=me&gt;
X-Cron-Env: &lt;HOME=/Users/me&gt;
Message-Id: &lt;20161018013004.514D0203328A@micheal.taylor-mbp&gt;
Date: Mon, 17 Oct 2016 19:30:00 -0600 (MDT)

Traceback (most recent call last):
  File "/Users/me/Documents/auto_updater/jira_updater.py", line 3, in &lt;module&gt;
    from jira.client import JIRA
ImportError: No module named jira.client
</code></pre>

<p>Originally I had problems with the #!/usr/bin/python path, so I switched it to #!/usr/bin/env python:</p>

<pre><code>[me@local] ~/Documents/auto_updater &gt; head jira_updater.py 
#!/usr/bin/env python

from jira.client import JIRA
import random

# Here's some responses that we can randomize from so it doesn't feel quite so botty.
FIRST_RESPONSES = ['- Do you need help moving this forward?',
                  '- Can I help you get traction on this?',
</code></pre>

<p>I've seen some workarounds that state that I just need my cronjob to run with my pythonpath explicitely declared, but that seems like a shoddy workaround, and I've set up a server to run this for me, so I'd prefer to solve it by making things work properly - but what I can't figure out is why the cronjob run command can't seem to find the module, but I can as root run it with the same syntax as specified in the crontab.  I've verified this by manually running the same commant specified in the crontab:</p>

<pre><code>me@local] ~/Documents/auto_updater &gt; crontab -l
*/30 * * * * python /Users/me/Documents/auto_updater/jira_updater.py &gt;&gt; /Users/me/Documents/auto_updater/updated_log.txt
</code></pre>

<p>Anyone have any insight into why cronjob can't find the module, or is specifying the pythonpath manually really the only "fix"?</p>

<p>probably explicitly append the lib path for jira in jira_updater.py should do.</p>

<pre><code># added code below before import jira
# append path where jira lib located, for example in /usr/bin/lib
import sys
sys.path.append('/usr/bin/lib')

# if yout don't know where jira located, use code below to get jira path first
# then put the path found into code sys.path.append above
import imp;imp.find_module('jira')
</code></pre>

python import cron jira