`pip install inference` installs three OpenCV distributions; `easyocr` pulls an unpinned `opencv-python-headless` 5.0 that competes with the pinned 4.x `cv2`
What happens
A clean pip install inference (1.7.4, Python 3.13, macOS arm64; same with uv pip install) ends up with three distributions that all own cv2/:
opencv-python 4.11.0.86 <- inference, inference-sdk, inference-models, roboflow-workflows (pinned <4.13 / <=4.13.0)
opencv-contrib-python 4.11.0.86 <- inference (requirements/_requirements.txt, pinned <4.13)
opencv-python-headless 5.0.0.93 <- easyocr 1.7.2 <- inference-models (core dependency, unpinned)
pip/uv treat them as unrelated packages, so all three install and the last one to unpack wins the cv2/ directory. Which one that is depends on resolver and install order:
uv pip install inference:import cv2gives 4.11.0 (the pinned build happened to unpack last).python -m pip install inference:import cv2gives 4.12.0 (same).
So a fresh install currently lands on the pinned 4.x build by luck of ordering. Any later operation that reinstalls headless flips it. For example, after the pip install above:
$ pip install --force-reinstall --no-deps opencv-python-headless==5.0.0.93 # what `pip install -U easyocr` would do
$ python -c "import cv2; print(cv2.__version__)"
5.0.0
$ pip check
No broken requirements found.
import cv2 now returns the headless 5.0 build, the opencv-python<4.13.0 pin added in #2357 (tensor-native Workflows) is silently defeated, and nothing in pip reports a problem because the three distributions are unrelated as far as metadata goes.
Why
inference_models/pyproject.toml lists easyocr~=1.7.2 as a core dependency (since the inference-exp → inference-models rename, 927d6dd24). easyocr depends on opencv-python-headless with no version bound, so it resolves to the newest release, which has been 5.0.0.93 since 2026-07-02.
The repo already recognises this class of problem: requirements/requirements.magevl.txt is installed with --no-deps precisely because "installing headless alongside the opencv-python this repo already pins puts two packages behind cv2", and the Jetson Dockerfiles override opencv-python-headless==4.12.0.88 (#1045). Neither applies to the PyPI install path through inference-models.
Reproduction
python3.13 -m venv v && v/bin/pip install inference
v/bin/pip list | grep -i opencv
v/bin/python -c "import cv2; print(cv2.__version__, hasattr(cv2, 'imshow'))"
Options
- Add
opencv-python-headless>=4.8.1.78,<4.13.0next to the existingopencv-python/opencv-contrib-pythonpins inrequirements/_requirements.txtandinference_models/pyproject.toml, so whichever package winscv2/is at least a supported 4.x build. Smallest change; keeps three packages installed. - Make
easyocran optional extra ofinference-models(it already hasrequirements/requirements.easyocr.txton the inference side), so the default install stops pulling headless at all. - Both.
Happy to open a PR for whichever you prefer.
I went through every OpenCV declaration in the tree at 649b479 and reproduced the resolution, in case a
full inventory helps you pick between the two options. Summary first: the diagnosis holds, easyocr is the
only source of opencv-python-headless, and one extra declaration needs fixing under either option.
Where each distribution is declared
Everything that reaches a pip install inference:
| File | Line | Declaration |
|---|---|---|
requirements/_requirements.txt |
10 | opencv-python>=4.8.1.78,<4.13.0 |
requirements/_requirements.txt |
11 | opencv-contrib-python>=4.8.1.78,<4.13.0 |
requirements/requirements.cli.txt |
8 | opencv-python>=4.8.1.78,<=4.13.0 |
requirements/requirements.sdk.http.txt |
5 | opencv-python>=4.8.1.78,<=4.13.0 |
workflows/pyproject.toml |
15 | opencv-python>=4.8.1.78,<4.13.0 |
stream_vision/pyproject.toml |
10 | opencv-python>=4.8.1.78,<4.13.0 |
inference_models/pyproject.toml |
11 | opencv-python>=4.8.1.78 — no upper bound |
opencv-python-headless is declared nowhere in the repo. It arrives only transitively, and the path is the
one you identified: requirements/requirements.cpu.txt:3 pins inference-models[torch-cpu,onnx-cpu]==0.39.5,
whose pyproject.toml:38 has easyocr~=1.7.2 as a core dependency, and easyocr 1.7.2's metadata lists a
bare opencv-python-headless with no specifier.
I checked whether anything else pulls it, since that would change which option actually works: it does not.
supervision 0.30.6 dropped its opencv-python-headless requirement, and in all three of
inference_models/uv.lock, workflows/uv.lock and stream_vision/uv.lock the sole reverse dependency of
opencv-python-headless is easyocr. So making easyocr optional really would stop headless being
installed by default — there is no second path to patch afterwards.
Two things worth flagging beyond the report
1. inference_models/pyproject.toml:11 has no <4.13.0 cap at all. The #2357 cap exists in
_requirements.txt, requirements.cli.txt, requirements.sdk.http.txt, workflows/pyproject.toml and
stream_vision/pyproject.toml, but not in inference-models. A standalone pip install inference-models
therefore gets opencv-python 5.0.0.93 for the main distribution too, not just headless:
$ pip install --dry-run --report r.json "opencv-python>=4.8.1.78"
opencv-python 5.0.0.93
That line needs the cap under either option, and it is independent of the easyocr question.
2. The inference distribution already treats EasyOCR as optional. .release/pypi/inference.setup.py:88
(and the .cpu, .gpu, .core variants) declare "easy-ocr": read_requirements("requirements/requirements.easyocr.txt")
as an extra, and requirements.easyocr.txt is not in any install_requires. That extra is currently dead —
easyocr installs unconditionally via inference-models regardless — which reads to me as evidence that
option 2 matches the original intent rather than being a new policy.
Reproduction
pip 26.2.2, Python 3.13, clean venv, metadata-only resolve of the repo's own pins plus the easyocr
constraint that inference-models imposes:
$ pip install --dry-run --report r.json \
"opencv-python>=4.8.1.78,<4.13.0" \
"opencv-contrib-python>=4.8.1.78,<4.13.0" \
"easyocr~=1.7.2"
opencv-python 4.12.0.88
opencv-contrib-python 4.12.0.88
opencv-python-headless 5.0.0.93 <- exit code 0, no conflict reported
Adding the bound from option 1 resolves cleanly and brings headless back in line:
$ pip install --dry-run --report r2.json \
"opencv-python>=4.8.1.78,<4.13.0" \
"opencv-contrib-python>=4.8.1.78,<4.13.0" \
"opencv-python-headless>=4.8.1.78,<4.13.0" \
"easyocr~=1.7.2"
opencv-python 4.12.0.88
opencv-contrib-python 4.12.0.88
opencv-python-headless 4.12.0.88 <- exit code 0
Two notes on why this has been quiet. inference_models/uv.lock locks
opencv-python-headless at 4.11.0.86, so the locked dev environment never sees a 5.x build — but
workflows/uv.lock and stream_vision/uv.lock both lock it at 5.0.0.93 already. And the Jetson 6.2.0 image
sidesteps the whole thing at build time: docker/dockerfiles/Dockerfile.onnx.jetson.6.2.0:490-492 writes a
uv --override file pinning all three of opencv-python, opencv-contrib-python and
opencv-python-headless to ==4.12.0.88. That is essentially option 1 applied in one image, which suggests
option 1 is at least an established remedy here.
The one thing I would not decide for you
requirements/requirements.magevl.txt:15-19 documents the opposite stance for the declared case —
codec-video-prep's opencv-python-headless<4.12 pin is deliberately kept away from the resolver with
--no-deps because "installing headless alongside the opencv-python this repo already pins puts two packages
behind cv2". Option 1 does not add a package that is not already installed, so I do not think it contradicts
that comment, but it does mean the repo would be formally declaring a dependency it has written a paragraph
about avoiding.
More substantively: option 1 guarantees whichever build wins cv2/ is a supported 4.x, but it does not make
the outcome deterministic — three wheels still own the directory and install order still decides. Option 2 is
the one that actually fixes that, at the cost of EasyOCR no longer working after a default
pip install inference-models (inference_models/inference_models/models/easy_ocr/easy_ocr_torch.py:4
imports easyocr at module scope, so it would need a guarded import and a clear error). The Dockerfiles and
the four CI workflows already pass requirements/requirements.easyocr.txt explicitly, so those would be
unaffected.
That trade-off is a product call rather than a packaging one, and AGENTS.md asks for package-dependency
changes to be agreed with maintainers before implementation, so I have not opened a PR. Happy to put one up
for whichever you prefer — I would guess option 1 plus the missing inference_models cap as an immediate fix,
with option 2 as a follow-up, but say the word and I will do it the other way round.
I reviewed the findings across the tree and ran the resolution commands above myself to verify the behavior.