Error importing psycopg2._psycopg when run through cron

250 views Asked by At

When I run the Python interperter directly, I have no problem with importing psycopg2

Python 3.5.1 |Anaconda custom (64-bit)| (default, Dec  7 2015, 11:16:01)  [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> from psycopg2._psycopg import *
>>>

But if I run import psycopg2 in a script executed through cron, I get the following error. How can I fix that so that it can run though cron as well?

import psycopg2, psycopg2.extras
File "/opt/anaconda3/lib/python3.5/site-packages/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: No module named _psycopg

As you can see, I am on Python 3.5 via Anaconda

0

There are 0 answers