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 `__main__.py 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
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.