Tomasz Osobiński
Tomasz Osobiński

Reputation: 71

Python ERROR: Could not build wheels for cx_Oracle, which is required to install pyproject.toml-based projects

I'm trying to install cx_Oracle and I get this error, I have the latest setuptools and pip installed. Has anyone had a similar problem and how did they solve it?

I have Visual Studio: please see image

Microsoft Visual C++ Redistributable Versions listed

Processing c:\....resources\cx_oracle-8.1.0.tar.gz
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: cx_Oracle
  Building wheel for cx_Oracle (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for cx_Oracle (pyproject.toml) did not run successfully.
  ¦ exit code: 1
  ?-> [7 lines of output]
      C:\....\2\pip-build-env-806_5jc6\overlay\Lib\site-packages\setuptools\config\expand.py:144: UserWarning: File 'C:\\....\\2\\pip-install-r8jb3ohi\\cx-oracle_111cfa7e3d91425bb65e9a6baa89c82f\\README.md' cannot be found
        warnings.warn(f"File {path!r} cannot be found")
      running bdist_wheel
      running build
      running build_ext
      building 'cx_Oracle' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for cx_Oracle
Failed to build cx_Oracle
ERROR: Could not build wheels for cx_Oracle, which is required to install pyproject.toml-based projects

Upvotes: 7

Views: 57260

Answers (5)

Alicia Peñaranda
Alicia Peñaranda

Reputation: 11

I downloaded oracledb and after that this error came up:

OperationalError: (oracledb.exceptions.OperationalError) DPY-6005: cannot connect to database (CONNECTION_ID=xxxxxxxxxxxxxxxx).
DPY-3010: connections to this database server version are not supported by python-oracledb in thin mode
Help: https://python-oracledb.readthedocs.io/en/latest/user_guide/troubleshooting.html#dpy-3010
(Background on this error at: https://sqlalche.me/e/20/e3q8)

The link drives you to the solution of enabling python-pracledb Thick mode. You can download it from here and do the call: oracledb.init_oracle_client()

import os
import platform
import oracledb

d = None                               # On Linux, no directory should be passed
if platform.system() == "Darwin":      # macOS
  d = os.environ.get("HOME")+("/Downloads/instantclient_23_3")
elif platform.system() == "Windows":   # Windows
  d = r"C:\oracle\instantclient_23_5"
oracledb.init_oracle_client(lib_dir=d)

Upvotes: 1

Pablo Bandeira
Pablo Bandeira

Reputation: 1

This the version. Request Python 3.10.9 for cx_Oracle.

Upvotes: -1

otuozeAhmed
otuozeAhmed

Reputation: 41

Alternatively, you can install Anaconda for your OS, and run the following command to install cx_oracle. Anaconda takes care of the entire build process (wheel issue).

conda install -c anaconda cx_oracle

cx_Oracle was already integrated into my project (alongside everyone on the team). I couldn't switch to oracledb. If you're starting a new project kindly pip install oracledb

Upvotes: 4

Anthony Tuininga
Anthony Tuininga

Reputation: 7086

The image you showed has redistributables, not Visual Studio itself! You will need to follow the provided link to get the Microsoft build tools installed if you want to build it yourself.

If you use pip, however, you should be able to download and install prebuilt binaries -- which is a LOT easier! The command to use is:

python -m pip install cx_Oracle

EDIT: cx_Oracle has been superseded by python-oracledb. Install that via this command:

python -m pip install oracledb

Upvotes: 7

siqing he
siqing he

Reputation: 1

mayBe beacause the version of python,when I use 3.10.9 is ok,but 3.11.0 not

Upvotes: -1

Related Questions