cx_Oracle install: No module named 'pkg_resources' (tested fix)

pip install cx_Oracle now fails with ModuleNotFoundError: No module named 'pkg_resources' during "Getting requirements to build wheel", even when your venv has setuptools. The isolated build gets setuptools 82+, which removed pkg_resources. Fixes tested below: switch to oracledb, or pip install --build-constraint with setuptools<81.

1. pip install cx_Oracle fails, even with setuptools installed

Fresh Python 3.11.17 venv (python -m venv) with pip 26.2.2. The venv itself had setuptools 79.0.1, which still includes pkg_resources:

$ pip install cx_Oracle
Collecting cx_Oracle
  Downloading cx_Oracle-8.3.0.tar.gz (363 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'error'
  error: subprocess-exited-with-error
[... traceback trimmed ...]
          ^^^^^^^^^^^^^^^^^^^^
        File "<string>", line 6, in <module>
      ModuleNotFoundError: No module named 'pkg_resources'
      [end of output]
  note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed to build 'cx_Oracle' when getting requirements to build wheel

cx_Oracle 8.3.0 (released 2021-11-04, the last release) has wheels only up to Python 3.10, so on 3.11+ pip builds it from the sdist. Its setup.py starts with import pkg_resources, and its pyproject.toml only asks for setuptools >= 40.6.0. pip builds in an isolated environment with the newest setuptools, and setuptools 82.0.0 removed pkg_resources. The setuptools in your venv is never used, which is why "but setuptools is installed" does not matter. uv pip install cx_Oracle failed the same way.

2. Best fix: switch to python-oracledb

cx_Oracle was renamed to oracledb, which ships prebuilt wheels. pip install oracledb installed 26.0.1 with no build step and no pkg_resources. Check Oracle's cx_Oracle-to-oracledb upgrade notes before switching existing code.

3. Keep cx_Oracle: constrain the build's setuptools

$ echo "setuptools<81" > build-constraints.txt
$ pip install --build-constraint build-constraints.txt cx_Oracle
Successfully built cx_Oracle
Installing collected packages: cx_Oracle
Successfully installed cx_Oracle-8.3.0

That built and installed cx_Oracle 8.3.0. With uv: uv pip install --build-constraint build-constraints.txt cx_Oracle also worked. Note: PIP_CONSTRAINT=build-constraints.txt pip install cx_Oracle still failed with the same error on pip 26.2.2, so use --build-constraint.

4. Or build with the venv's own setuptools

If the venv has setuptools <82 (here 79.0.1):

$ pip install --no-build-isolation cx_Oracle
Installing collected packages: cx_Oracle
Successfully installed cx_Oracle-8.3.0

This needs a C compiler, and every build dependency must already be in the venv.

Same root cause elsewhere: No module named 'pkg_resources' (general fix) · TensorBoard · librosa.

Frequently asked questions

Why does installing setuptools not fix the cx_Oracle error?

pip builds cx_Oracle in an isolated environment with the newest setuptools (82+, no pkg_resources); your venv's setuptools is not used. Use --build-constraint with setuptools<81 or --no-build-isolation.

What replaces cx_Oracle?

python-oracledb (pip install oracledb), its renamed successor with prebuilt wheels.

Written with AI assistance. Measured on 2026-10-24 on Linux with Python 3.11.17: pip 26.2.2 (python -m venv, setuptools 79.0.1) and uv; cx_Oracle 8.3.0 sdist, oracledb 26.0.1. Output pasted unedited except shortened paths, temp dir names and marked trims. PlainTables is our extension; cx_Oracle and oracledb are free.