0

Starting from this question, I can't get my crontab to recognize any of the packages I've installed when I'm trying to automate a python, even though it works when I run it in the terminal.

A lot of people have had this problem and there doesn't seem to be an acceptable solution yet, so I'm trying to get to the bottom of it.

When I run a test file with crontab that has the contents:

#!/usr/local/env python2.7


print ("with just python")

import sys
print(sys.version)

I get the output:

2.7.10 (default, Jul 30 2016, 18:31:42) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]

But when I run it in Spyder, I get the output:

2.7.14 |Anaconda, Inc.| (default, Oct  5 2017, 02:28:52) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]

I haven't (purposefully) installed multiple pythons on this computer, it's a brand-new mac and I simply downloaded Anaconda. I'm pretty certain that crontab can't see my packages because of this slight difference, but my question then becomes how can I install a package to 2.7.10? Or even know where those site-packages are kept?

skathan
  • 641
  • 7
  • 16

1 Answers1

0

Figured this out, so posting for others. All I did is added /anaconda2/bin/python to my crontab

*/1 * * * *  /anaconda2/bin/python  /Users/kelinho/cron_test.py

and this worked perfectly. Using which python in terminal helped me figure out which version of python I needed to call.

skathan
  • 641
  • 7
  • 16