openai CLIP: No module named 'pkg_resources' on pip install (tested)

pip install git+https://github.com/openai/CLIP.git@<commit> fails with ModuleNotFoundError: No module named 'pkg_resources' at "Getting requirements to build wheel". Tested fixes: install from current main, or keep the commit and add --build-constraint with setuptools<81.

1. The error: pip install of an older CLIP commit

A lot of notebooks, Dockerfiles and forks pin CLIP to an older commit. We installed one (dcba3cb, from before the fix) with pip 26.2.2 in a fresh Python 3.11 venv. We used --no-deps so the test didn't pull in torch:

$ pip install --no-deps git+https://github.com/openai/CLIP.git@dcba3cb2e2827b402d2701e7e1c7d9fed8a20ef1
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'error'
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [21 lines of output]
      Traceback (most recent call last):
        [... trimmed ...]
        File "<string>", line 3, 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.
  [... trimmed ...]

Line 3 of CLIP's old setup.py is import pkg_resources. pip builds the package in an isolated environment with the newest setuptools. setuptools 82.0.0 removed pkg_resources, so the build fails at "Getting requirements to build wheel". The build doesn't use your venv's setuptools (we confirmed that with cx_Oracle, linked below).

2. Fix 1: install from current main

CLIP's main branch no longer imports pkg_resources in setup.py (it was removed in February 2026; we tested commit d05afc4). clip/clip.py uses from packaging import version at both commits, so the import itself is fine.

$ pip install --no-deps git+https://github.com/openai/CLIP.git
  Resolved https://github.com/openai/CLIP.git to commit d05afc436d78f1c48dc0dbf8e5980a9d471f35f6
Successfully built clip
Successfully installed clip-1.0

3. Fix 2: keep your pinned commit, cap setuptools for the build

If you need the old commit, pass a build constraint so the isolated build uses setuptools<81 (pip 26.2+):

$ echo "setuptools<81" > build-constraints.txt
$ pip install --no-deps --build-constraint build-constraints.txt git+https://github.com/openai/CLIP.git@dcba3cb2e2827b402d2701e7e1c7d9fed8a20ef1
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
Successfully built clip
Successfully installed clip-1.0

Running pip install "setuptools<81" in your venv does not help on its own, because the build environment is separate. --no-build-isolation also works if setuptools<81 is installed in the venv. We tested that route on cx_Oracle, not on CLIP.

Same root cause elsewhere: No module named 'pkg_resources' (general fix) · Stable Diffusion WebUI (installs an old CLIP commit) · cx_Oracle (build isolation) · TensorBoard · selenium-wire.

Frequently asked questions

Why doesn't pip install setuptools<81 fix the CLIP install?

pip builds CLIP in an isolated environment that downloads the newest setuptools. Use --build-constraint (pip 26.2+) or --no-build-isolation.

Does current openai/CLIP main still need pkg_resources?

No. setup.py on main stopped importing pkg_resources in February 2026, and in our test main built and installed cleanly.

Written with AI assistance. Measured on 2026-10-24 on Linux with Python 3.11.17 and pip 26.2.2, installing openai/CLIP from GitHub with --no-deps (old commit dcba3cb and main d05afc4). Output pasted unedited except shortened paths and marked trims. PlainTables is our extension; CLIP is free (MIT).