I have cx_Oracle installed in a python venv, and when I try to use it I get:
>>> import cx_Oracle
>>> cx_Oracle.connect("blabla")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory". See https://oracle.github.io/odpi/doc/installation.html#linux for help
Did you use Nix to have the python environment provided?
For me, it still works just fine in a nix-shell:
❯ nix-shell -p python3.pkgs.cx_oracle --run python
Python 3.7.5 (default, Oct 14 2019, 23:08:55)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>> cx_Oracle.connect("blabla")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cx_Oracle.DatabaseError: ORA-12162: TNS:net service name is incorrectly specified
>>>
Found it, should have a paid more attention, it was in the “How to consume python modules using pip in a virtual environment like I am used to on other Operating Systems?” section.
The python cx_oracle contains c bindings. If cx_oracle was installed via pip, these bindings are probably binaries coming from a tarball, and don’t know where and how to find the underlying odpic/oracle-instantclient.so files.
I always recommend using Nix to provide the complete python environment. I’m not really familiar with impurePythonEnv - (maybe remove cx_oracle from the pip-provided folders?) but I wouldn’t want to mix these things…