Installing cx-Oracle on Oracle Linux 7.9

I am trying to install cx-Oracle package so I can write scripts connecting to Oracle database. I get the following error.

# python3 -m pip install cx-Oracle
WARNING: Running pip install with root privileges is generally not a good idea. Try ` install --user` instead.
Collecting cx-Oracle
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb91ea93048>: Failed to establish a new connection: [Errno 111] Connection refused',)': /simple/cx-oracle/
  Could not find a version that satisfies the requirement cx-Oracle (from versions: )
No matching distribution found for cx-Oracle

This is my python and pip version.

[root@ohvw8205 pip-23.1.2]# python3 --version
Python 3.6.8
[root@ohvw8205 pip-23.1.2]# python3 -m pip --version
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)

Is pip installed properly?


This sound like the machine doesn’t have network access.

In which case, is there a way to install the pip or cx_Oracle package manually ?

As @jeanas mentioned, pip is working perfectly fine; the problem is you apparently do not have network access to PyPI to download and install cx-Oracle. Before trying manual workarounds, you should talk to your system/network administrator about this; there may be good reasons for it.

However, you can indeed download PyPI packages manually, by downloading the appropriate wheel for your platform from the package’s Files list on PyPI; in this case, I’m guessing you’re on RHEL8 or similar, and thus this wheel is the one you want. Copy the wheel on to the target machine, and then run pip install path/to/wheel.whl to install it. cx-Oracle doesn’t have any dependencies, so you just need to install the one wheel

Something else important, though—per its docs, the project named cx-Oracle is no longer developed or updated, and new and better versions are now developed under the (much more logical and less cryptic) project name oracledb, and it is strongly recommended you use that instead. For that, you’ll need to download and install the appropriate wheel, just as the above, as well as the wheel for cryptography which it has apparently taken on as a dependency.

Best of luck!

1 Like

On OL8 you can dnf i stall python3-cx_Oracle I do not have an OL7 to check on.
Then you do not need pip to work.

Thanks for the help. I downloaded the wheel file for oracledb
my python version is 3.6

[root@ohvw8205 ~]# python3 -m pip --version
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)

[root@ohvw8205 ~]# python3 -m pip install oracledb-1.3.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
WARNING: Running pip install with root privileges is generally not a good idea. Try install --user instead.
oracledb-1.3.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl is not a supported wheel on this platform.
My OS - Linux 5.4.17-2102.201.3.el7uek.x86_64