ImportError: No module named SQLAlchemy with Anaconda
<p>I have a python script that works on all other remote servers I've run it on but for some reason on a particular remote server where I have Anaconda installed I'm getting an ImportError for SQLAlchemy. I am connecting to a MySQL db. </p>

<pre><code>#!/usr/bin/python
from sqlalchemy import *
from sqlalchemy.orm import sessionmaker, mapper
import sys
dev_engine = create_engine('mysql://...')
prod_engine  = create_engine('mysql://...')

def transactions(exchange, filepath):
    dev_connect = dev_engine.connect()
    prod_connect = prod_engine.connect()

    get_dev_instrument = "select * from " + exchange + "_instrument;"
    instruments = dev_engine.execute(get_dev_instrument)
    instruments_list = [r for r in instruments]
    get_prod_instrument = "select * from " + exchange + "_instrument;"
    instruments_after = prod_engine.execute(get_prod_instrument)
    instruments_after_list = [r2 for r2 in instruments_after]

    ...
</code></pre>

<p>I am getting the following error when trying to run it. </p>

<pre><code>  File "/home/local/filepath/general.py", line 2, in &lt;module&gt;
    from sqlalchemy import *
  ImportError: No module named sqlalchemy
</code></pre>

<p>However if I run the python shell, I can import sqlalchemy</p>

<pre><code>my.username@remote-server:~$ python
Python 2.7.11 |Anaconda 2.4.1 (64-bit)| (default, Dec  6 2015, 18:08:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
&gt;&gt;&gt; from sqlalchemy import *
&gt;&gt;&gt;
</code></pre>

<p>What is wrong?</p>

<p>EDIT: If I call my script from its directory, it works perfectly fine. I am calling the script using the full filepath since I am trying to run it from Crontab. </p>

<pre><code>my.username@remote-server:~$ python general.py arg1 arg2
formed maps
my.username@remote-server:~$

my.username@remote-server:~$: /usr/bin/python /home/local/TMG/filepath/general.py arg1 arg2


Traceback (most recent call last):
  File "/home/local/TMG/filepath/general.py", line 2, in &lt;module&gt;
    from sqlalchemy import *
ImportError: No module named sqlalchemy
</code></pre>