3

I tried to install cx_Oracle from pypi source since there is no available port for it in cygwin. I did make some changes as suggested in http://permalink.gmane.org/gmane.comp.python.db.cx-oracle/2492 and modified my setup.py. However, I still get the following error :-

$ python
Python 2.7.3 (default, Dec 18 2012, 13:50:09)
[GCC 4.5.3] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
/usr/lib/python2.7/site-packages/cx_Oracle-5.1.3-py2.7-cygwin-1.7.24-i686.egg/cx_Oracle.py:3: UserWa
rning: Module cx_Oracle was already imported from /usr/lib/python2.7/site-packages/cx_Oracle-5.1.3-p
y2.7-cygwin-1.7.24-i686.egg/cx_Oracle.pyc, but /home/zerog/cx_Oracle-5.1.3 is being added to sys.pat
h
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.cygwin-1.7.24-i686/egg/cx_Oracle.py", line 7, in <module>
  File "build/bdist.cygwin-1.7.24-i686/egg/cx_Oracle.py", line 6, in __bootstrap__
ImportError: Exec format error
>>>

If someone can please help me fix this ?

TIA.

ZeroGraviti
  • 1,047
  • 2
  • 12
  • 28
  • I cd'ed to a different dir and get the following output :- `$ python Python 2.7.3 (default, Dec 18 2012, 13:50:09) [GCC 4.5.3] on cygwin Type "help", "copyright", "credits" or "license" for more information. >>> import cx_Oracle Traceback (most recent call last): File "", line 1, in File "build/bdist.cygwin-1.7.24-i686/egg/cx_Oracle.py", line 7, in File "build/bdist.cygwin-1.7.24-i686/egg/cx_Oracle.py", line 6, in __bootstrap__ ImportError: Exec format error >>>` – ZeroGraviti Jun 19 '14 at 02:14

3 Answers3

1

Fixed this by specifying the path to instantclient as below :

$ export PATH=$PATH:/cygdrive/d/Tools/instantclient_11_2

(Other, possibly important stuff) :

$ echo $LD_LIBRARY_PATH
/cygdrive/d/Tools/instantclient_11_2
$ echo $ORACLE_HOME
/cygdrive/d/Tools/instantclient_11_2

Now, I get :-

$ python
Python 2.7.3 (default, Dec 18 2012, 13:50:09)
[GCC 4.5.3] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>>
ZeroGraviti
  • 1,047
  • 2
  • 12
  • 28
  • I'm seeing this error too, but I have PATH, ORACLE_HOME, TNS_ADMIN, and LD_LIBRARY_PATH set in .profile (using cygwin paths, installed the 32 bit oracle client). Were there any other changes you made? I am using slightly newer versions (Python 2.7.5, GCC 4.8.1). I am able to run setup.py and compile (had to remove the reference to -mno-cygwin), but I cannot import the module. – Kevin Seifert Jul 03 '14 at 16:57
  • Can you give a log of your console error when you try to import ? Also, check the version of your oracle instant client. Is there something else from either my local changes to files in my filesystem or environment variables which you need ? Also, can you check the necessary file permissions and file owners. Can you share setup.py or any other files which you changed and I can check the diffs (if any)... – ZeroGraviti Jul 05 '14 at 13:54
  • 1
    Also, check if you have python installed using a windows installer or if you installed it from cygwin. I only have a cygwin python installed on my windows based system. You can of course choose to use and triage with `virtualenv` – ZeroGraviti Jul 05 '14 at 14:52
  • Thanks! I'll look into these options. I have python installed via cygwin currently ... which is possibly the problem. – Kevin Seifert Jul 07 '14 at 16:24
  • Looks like that fixed the issue...I tried the Windows install of python :) `easy_install cx_Oracle` works for a binary install. `pip` requres visual studio. – Kevin Seifert Jul 07 '14 at 17:06
  • Previously I was seeing the same error message "ImportError: Exec format error". Also with -v I saw dlopen("/usr/lib/python2.7/site-packages/cx_Oracle-5.1.3-py2.7-cygwin-1.7.30-x86_64.egg/cx_Oracle.dll", 2); /bin/python: Exec format error. (I'm on Windows 7 64 bit though I'm using 32 bit Oracle and 32 bit Cygwin ... I didn't try all 64 bit). – Kevin Seifert Jul 07 '14 at 17:15
0

It's hard to pin down from the error message alone, but I am guessing that you have two different copies of cx_Oracle in your sys.path. The error message is complaining that a different version of the same module had already been import-ed.

Presumably the pristine upstream version is installed system-wide in /usr/lib/python2.7/site-packages/cx_Oracle-5.1.3-py2.7-cygwin-1.7.24-i686.egg, and your modified version in /home/zerog/cx_Oracle-5.1.3.

Does it work if you pare down sys.path so that only the original, or only your modified version, is included?

(You might want to use virtualenv if you need to switch back and forth between two versions frequently.)

Dan Lenski
  • 76,929
  • 13
  • 76
  • 124
  • I am not sure why the modified version is being 'add'-ed. Any suggestions how to 'pare down sys.path' ? Essentially, I built cx_Oracle from the source folder /home/zerog/cx_Oracle-5.1.3 and the egg which was installed is in the py2.7 site-packages folder. – ZeroGraviti Jun 19 '14 at 02:08
  • How can I install cx_Oracle from my src folder (/home/zerog/cx_Oracle-5.1.3) into the virtualenv's (e.g., /foo/bar/env/lib/python2.7/site-packages) library folder ? – ZeroGraviti Jun 19 '14 at 02:23
0

I ran into this error "Exec format error."

For me, this was likely caused by a mismatch between cygwin being installed as 64 bit, but the instant client being installed as 32 bit. Double check that everything (oracle, cygwin) is either 32 bit or 64 bit.

What fixed my issue:

  1. Since my cygwin is 64 bit (see uname -a, and look for x86_64), I downloaded the 64 bit instant client from oracle's website, and unzipped

  2. I set the env vars in .profile, to point where it was unzipped:

    export ORACLE_HOME=/cygdrive/c/oracle/instantclient_x64_11_2

    export LD_LIBRARY_PATH=$ORACLE_HOME

    export DYLD_LIBRARY_PATH=$ORACLE_HOME

    export TNS_ADMIN='//optional/path/to/your/oracle/tns/files/'

  3. source ~/.profile

  4. To test, you should now be able to run this python command with no error:

    import cx_Oracle

To verify the path is correct, if you run ls, you should see something like

ls $ORACLE_HOME

adrci.exe     genezi.exe  oci.sym        ociw32.dll  ojdbc6.jar          
oraocci11.dll   oraociei11.sym  uidrvci.exe  vc9
adrci.sym     genezi.sym  ocijdbc11.dll  ociw32.sym  orannzsbb11.dll  
oraocci11.sym   orasql11.dll    uidrvci.sym  xstreams.jar
BASIC_README  oci.dll     ocijdbc11.sym  ojdbc5.jar  orannzsbb11.sym
oraociei11.dll  orasql11.sym    vc8
Kevin Seifert
  • 3,494
  • 1
  • 18
  • 14