MySQLdb module works when running Python script from the command line, but not as a cron job -
i trying create cron job run python script wrote, reason script runs when i'm running command line. worked before, accidentally deleted crontab. when crontab wrote tries run it, error mysqldb module being wrong architecture:
traceback (most recent call last): file "/users/myuser/documents/ee_sfdc integration/csv_reader/weekly_updates/weekly_confirmation/weekly_confirm.py", line 7, in <module> import mysqldb file "/library/python/2.7/site-packages/mysqldb/__init__.py", line 19, in <module> import _mysql importerror: dlopen(/library/python/2.7/site-packages/_mysql.so, 2): no suitable image found. did find: /library/python/2.7/site-packages/_mysql.so: mach-o, wrong architecture
in crontab, i've tried using full path several python versions (2.7 , 3.4), still issue. when use 3.4, don't error mysqldb, do error on print .forma() statement being wrong syntax.
but again, doesn't happen when run script command line, expect not correct version either.
the cron job looks this:
14 12 * * * today=`date +"\%y-\%m-\%d"` && /system/library/frameworks/python.framework/versions/2.7/bin/python2 /users/myuser/documents/ee_sfdc\ integration/csv_reader/weekly_updates/weekly_confirmation/weekly_confirm.py > /users/myuser/documents/ee/run_logs/weekly_sync_runlog_$today.txt 2>&1
any appreciated!
the error message typically means have mismatch between mysqldb (or dependency) , python architecture.
that is, 1 of them 64-bit, while other 32-bit.
what happens if try following in terminal?
$ /system/library/frameworks/python.framework/versions/2.7/bin/python2 (take note of exact version) >>> import platform >>> print platform.architecture() >>> import mysqldb
do again, time python path , see if differ
$ python >>> import platform >>> print platform.architecture() >>> import mysqldb
edit:
you might check file, architecture module built for.
$ file /library/python/2.7/site-packages/_mysql.so /library/python/2.7/site-packages/_mysql.so: mach-o universal binary 2 architectures /library/python/2.7/site-packages/_mysql.so (for architecture x86_64): mach-o 64-bit bundle x86_64 /library/python/2.7/site-packages/_mysql.so (for architecture i386): mach-o bundle i386
Comments
Post a Comment