Can't import the cx_Oracle module unless I'm using an interactive shell
Question: When using Python on an interactive shell I'm able to import the cx_Oracle
file with no problem. Ex:

    
    
    me@server~/ $ python
    Python 2.7.6 (default, Mar 22 2014, 22:59:56)
    [GCC 4.8.2] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import cx_Oracle
    >>> 
    

As you can see, importing works without a hitch. However, when I try to run a
Python script doing the same thing, I get an error:

    
    
    me@server~/ $ sudo script.py
    Traceback (most recent call last):
       File "/usr/local/bin/script.py", line 19, in <module>
          import cx_Oracle
    ImportError: No module named "cx_Oracle'
    

Here is the important section from script.py:

    
    
    # 16 other lines above here
    # Imports
    import sys
    import cx_Oracle
    import psycopg2
    ...
    

I'm befuddled here. Other pertinent information is the server I'm running is
Ubuntu 14.04.1 LTS (upgraded from 12.04) 64bit. `which python` and `sudo which
python` both point to the same location. Also, doing this as root via `sudo su
-` gets the same results; import OK from interactive but error from script.

Nothing other than the OS upgrade happened between when this worked and when
it stopped working.


Answer: Sorry, all. This was a silly on my part. Turns out the script in question was
using Python3, and when the server upgraded, Python3 went from being 3.2
version to being 3.4 version.

Once the cx_Oracle module was set up in the 3.4 version, everything worked as
expected.

Phil, your final note talking about the shebang was what lead me to discover
this, so kudos to you! The reason I didn't mark your response as the answer
was because technically it wasn't but led me on the right path.

Cheers!

