Вопрос

I've followed the directions here http://maxolasersquad.blogspot.com/2011/04/cxoracle-on-ubuntu-1104-natty.html to install cx_Oracle on my machine.

I've installed Oracle Client 11.2 and cx_Oracle 11g for Python 3.3, both 64 bit. cx_Oracle is listed as a module using help('modules'), however I'm getting the following error message on import:

Traceback (most recent call last):
   File "<pyshell#0>", line 1, in <module>
    import cx_Oracle
ImportError: libclntsh.so.11.1: cannot open shared object file: No such file or directory

It would seem I'm missing a file, but I'm not sure if I need to install a dependency, or if some configuration is not setup correctly to point to the client.

Thanks for your assistance with this.

Edit:

Update, when I run echo $ORACLE_HOME and echo $LD_LIBRARY_PATH, I get the expected values now. However, the error still shows.

Это было полезно?

Решение

If you followed the guide that you referenced, you've also created a script in /etc/profile.d/. Make sure that this script ends in .sh.

Your problem is probably related to loading the script from this directory, which I'm guessing is because you're running python from a non-login bash shell.

To verify that this is the case, try to invoke bash with bash --login, or do source /etc/profile in an existing bash shell. Then check if the variables ORACLE_HOME and LD_LIBRARY_PATH gets defined with a sensible value.

If that works, there are some relevant questions (and answers!) on scripts in /etc/profile.d at AskUbuntu that might be helpful:

--

edit:

The environment variables are inherited – if the shell has a variable, then anything started from that shell should inherit those variables.

With this in mind, try to do:

$ bash --login
$ python
>>> import os
>>> print os.environ.get('ORACLE_HOME', '<not set>')
>>> print os.environ.get('LD_LIBRARY_PATH', '<not set>')
>>> import cx_Oracle

Другие советы

Did you export ORACLE_HOME and LD_LIBRARY_PATH variable?

I think LD_LIBRARY_PATH is not up. If not set it in your environement:

LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH

edit:

ok, what happen if you run just sqlplus?

Did you set NLS_LANG?

Try for example

export NLS_LANG=american_america.WE8ISO8859P1;
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top