1

My setup has:

- oracle-instantclient (downgraded from 12 to 11)
- Virtual Environment with Python + Django + cx_Oracle

When I downgraded the oracle-instantclient, I tried to reinstall cx_oracle using:

pip install --upgrade --force-reinstall cx_Oracle

The problem is that cx_Oracle keeps complaining that I'm not using the previous installed version 12:

$ python -c "import cx_Oracle"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: libclntsh.so.12.1: cannot open shared object file: No such file or directory

So, some questions here: "--force-reinstall" is not supposed to make a full reinstall, including a module recompile (aka cx_Oracle)? Somebody has some suggestion about how to workaround this issue? I looked at the pip manual and just tells me that it reinstalls the package. Not very useful.

Update1:

I tried to follow the solution here, adding my cx_Oracle path to the LD_LIBRARY_PATH but it's still not working.

echo $LD_LIBRARY_PATH
/usr/lib/oracle/11.2/client64/lib:/home/myuser/myuserenv/lib/python3.5/site-packages/cx_Oracle-5.2.1.dist-info

Note that my root user has a different python while my virtualenv uses its own python installation.

[root@myserver]# which python
/usr/bin/python

From my virtual environment:

(myvirtualenv) [myuser@myserver]$ which python
~/myvirtualenv/bin/python

Is there some way of installing cx_Oracle manually using my root user but putting the files at the virtual environment somehow?

Update2:

I tried to download cx_Oracle and compile manually using the following command:

sudo -u myuser ~/myvirtualenv/bin/python setup.py build install

But now I'm seeing some permission errors:

(...)
error: could not create 'build/bdist.linux-x86_64/egg': Permission denied

Am I doing the right thing? I don't want to mess this environment. Thanks.

Community
  • 1
  • 1
Arthur Accioly
  • 801
  • 9
  • 26
  • No, reinstalling won't help. Add path to cx_Oracle libs to your `LD_LIBRARY_PATH` environment variable. http://stackoverflow.com/questions/11654090/issue-building-cx-oracle-libclntsh-so-11-1-not-found – SergeyLebedev Nov 14 '16 at 21:39
  • Hum... I tried but didn't work... I exported my LD_LIBRARY_PATH to add the ...[myvirtualenv]/lib/python3.5/site-packages and /lib/python3.5/site-packages/cx_Oracle-5.2.1.dist-info, but still having the same error... Some other suggestion? – Arthur Accioly Nov 14 '16 at 21:57
  • Please note that I can use sqlplus without any problem, so it's a problem just with cx_Oracle... – Arthur Accioly Nov 14 '16 at 21:58

2 Answers2

2

The answer to your question (although you seem to have had another problem) is as follows: It depends on the module's structure. If its setup script calls the compiler, then yes it does. Because, you see, pip modules by default do not include compiled parts, it's up to the module author to provide them.

Dmitry Orlov
  • 454
  • 6
  • 14
0

I could finally install. The problem is that I had to use the python of my virtualenv. A simple solution but that I completely missed.

Steps:

pip download cx_Oracle
tar -xvf cx_Oracle-5.2.1.tar.gz
~/myenv/bin/python setup.py -v build
sudo ~/myenv/bin/python setup.py install

Note that I had to use sudo in the last step. Without this I was having this permission error:

error: could not create 'build/bdist.linux-x86_64/egg': Permission denied
Community
  • 1
  • 1
Arthur Accioly
  • 801
  • 9
  • 26