2

I'm having a very strange issue that I can't quite figure out and hope you all can. Following the steps at this link, I've installed the Oracle instant client and cx_Oracle, and I can import cx_Oracle in Python no problem. I've done all of this in a virtualenv.

The issue is when I try

./manage.py runserver

I get

raise ImproperlyConfigured("Error loading cx_Oracle module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading cx_Oracle module:
dlopen(/Users/shawn/Virtual/Django18/lib/python2.7/site-packages/cx_Oracle.so,
2): Library not loaded: /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1
Referenced from: /Users/shawn/Virtual/Django18/lib/python2.7/site-packages/cx_Oracle.so
Reason: image not found

Of course, that's exactly where the cx_Oracle.so file exists.

So I searched and found this SO question, but running the Ruby script actually breaks my cx_Oracle import in python, and doesn't resolve the django issue. Instead, it gives the error below, whether in Python directly or in the django environment. How do I fix this? I need to be able to import cx_Oracle in django! Thanks!

ImportError: dlopen(/Users/shawn/Virtual/Django18/lib/python2.7/site-packages/cx_Oracle.so,
2): Library not loaded: /Users/Shawn/Oracle/instantclient_11_2/
Referenced from: /Users/shawn/Virtual/Django18/lib/python2.7/site-packages/cx_Oracle.so
Reason: no suitable image found.  Did find:
/Users/Shawn/Oracle/instantclient_11_2/: not a file
/Users/Shawn/Oracle/instantclient_11_2/: not a file
/usr/local/lib/: not a file
/usr/lib/: not a file

EDIT: I wiped and recreated my virtualenv. I then retried the Ruby script after I realized that I didn't run it in the same directory as the instant client executables. It ran and updated from

@executable_path/...
to
/Users/shawn/Oracle/...

I tried importing cx_Oracle in my virtualenv python and this time it worked instead of throwing an error. Unfortunately, trying to run my django server still blows up saying

Raise ImproperlyConfigured("Error loading cx_Oracle module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading cx_Oracle module: dlopen(/Users/shawn/Virtual/Django18/lib/python2.7/site-packages/cx_Oracle.so, 2): Library not loaded: libclntsh.dylib.11.1
Referenced from: /Users/shawn/Virtual/Django18/lib/python2.7/site-packages/cx_Oracle.so
Reason: image not found

I can't understand why python can import it but django cannot.

Community
  • 1
  • 1
Shawn
  • 717
  • 11
  • 31

1 Answers1

0

Follow the instructions at the bottom of this page to do the installation of the Oracle instant client:

http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html

You may also need to set DYLD_LIBRARY_PATH or adjust things using otool -L and install_name_tool.

Anthony Tuininga
  • 6,388
  • 2
  • 14
  • 23
  • I tried those instructions, which were identical to what I did except for the additional portion about ~/lib. No joy. The Ruby script mentioned in my question adjusts things using otool -L and install_name_tool. Thanks anyways. – Shawn May 11 '16 at 00:27
  • You're welcome. I am no Mac expert but I do have access to a Mac and can try these steps myself. I am also familiar with Django so will let you know if I can replicate. – Anthony Tuininga May 11 '16 at 04:57