VS code won't install opencv

I have a new computer so have installed python v 3.14, and the newest VS Code IDE. But when I try to install opencv (pip install opencv-python) I get the following.

(myvenv) C:\Users\xxx\Documents\MyPythonFolder>pip install opencv-python
Collecting opencv-python
Using cached opencv_python-4.12.0.88-cp37-abi3-win_amd64.whl.metadata (19 kB)
Collecting numpy<2.3.0,>=2 (from opencv-python)
Using cached numpy-2.2.6.tar.gz (20.3 MB)
Installing build dependencies … done
Getting requirements to build wheel … done
Installing backend dependencies … done
Preparing metadata (pyproject.toml) … error
error: subprocess-exited-with-error

× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [21 lines of output]

  • C:\Users\xxx\Documents\MyPythonFolder\myvenv\Scripts\python.exe C:\Users\xxx\AppData\Local\Temp\pip-install-y8k8fcdk\numpy_46815f35414146c686e6d506f1ae0576\vendored-meson\meson\meson.py setup C:\Users\xxx\AppData\Local\Temp\pip-install-y8k8fcdk\numpy_46815f35414146c686e6d506f1ae0576 C:\Users\xxx\AppData\Local\Temp\pip-install-y8k8fcdk\numpy_46815f35414146c686e6d506f1ae0576.mesonpy-0z5u_5ea -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=C:\Users\RHELenovo\AppData\Local\Temp\pip-install-y8k8fcdk\numpy_46815f35414146c686e6d506f1ae0576.mesonpy-0z5u_5ea\meson-python-native-file.ini
    The Meson build system
    Version: 1.5.2
    Source dir: C:\Users\xxxxx***\AppData\Local\Temp\pip-install-y8k8fcdk\numpy_46815f35414146c686e6d506f1ae0576
    Build dir: C:\Users\***xxxxxx\AppData\Local\Temp\pip-install-y8k8fcdk\numpy_46815f35414146c686e6d506f1ae0576.mesonpy-0z5u_5ea
    Build type: native build
    Project name: NumPy
    Project version: 2.2.6
    WARNING: Failed to activate VS environment: Could not parse vswhere.exe output
  ..\meson.build:1:0: ERROR: Unknown compiler(s): [['icl'], ['cl'], ['cc'], ['gcc'], ['clang'], ['clang-cl'], ['pgcc']]
  The following exception(s) were encountered:
  Running `icl ""` gave "[WinError 2] The system cannot find the file specified"
  Running `cl /?` gave "[WinError 2] The system cannot find the file specified"
  Running `cc --version` gave "[WinError 2] The system cannot find the file specified"
  Running `gcc --version` gave "[WinError 2] The system cannot find the file specified"
  Running `clang --version` gave "[WinError 2] The system cannot find the file specified"
  Running `clang-cl /?` gave "[WinError 2] The system cannot find the file specified"
  Running `pgcc --version` gave "[WinError 2] The system cannot find the file specified"

  A full log can be found at C:\Users\RHELenovo\AppData\Local\Temp\pip-install-y8k8fcdk\numpy_46815f35414146c686e6d506f1ae0576\.mesonpy-0z5u_5ea\meson-logs\meson-log.txt
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> numpy

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

I successfully installed numpy

I tried reinstalling VS Code but the error still happens.

My system is Windows 11 with all the current updates on a Lenovo I5 laptop.

Any help would be appreciated as I am trying to learn OpenCV for a project.

Thanks

Fred

Python 3.14 was released in october 2025.

opencv-python 4.12 was released in july 2025, which is before Python 3.14 was released.

opencv 4.12 requires numpy <2.3.0.

numpy 2.2.6 has no binary package for Python 3.14.

Try it with Python 3.13 instead.

Tried it with 3.12 with the same outcome. Should I downgrade numpy too?

use PyPI, browse the available versions, browse the available downloads. look for files containing the string cp313 or cp312 (CPython 3.13, 3.12) or abi3 (broad compatibility).

“same outcome” cannot be. numpy 2.2.6 is available as a binary for Python 3.12.

Thanks for you help. I uninstalled all my python versions and then reinstalled the 3.12.10 version. OpenCV now installs fine. I guess VSCode was still trying to use the python version 3.14.

However, this brings up a concern I have as I am a retired SQA Engineer with over 25 years of software and hardware testing. Was there no Release Notes saying that specific versions of packages cannot (or should not) be used with version 3.14? I always required that - OR had the developers have some other type of safeguards so that “incompatible” add on software was warned about this type of developments.

Thanks again for your help.

F

It is what it is. Dependency resolution is not a solved problem. You know that.

The issue here is time travel paradoxes. And ways of specifying dependencies so that the install does not have to try building anything, because building something isn’t always successful.

OpenCV uses the abi3 interface to Python. That ensures forward-compatibility, so OpenCV does not have to say “Python <= 3.13” when it’s not actually required by OpenCV. The package can run on future Pythons that didn’t exist when the package was built.

This abi3 allows packages to compile once, rather than for every single minor Python version (3.14, 3.13, 3.12, 3.11, 3.10, 3.9, …). If one did that, one would have to keep a fairly insane cross product of OpenCV versions and Python versions, and there would be no forward-compatibility unless you bothered compiling older OpenCV versions for new Python versions.

This also allows for dependency resolution to fail: OpenCV can run on future Pythons on which other dependencies cannot run yet, because they don’t use the abi3 mechanism but require a specific Python version.

Numpy does not use the abi3 mechanism. They build packages for specific minor Python versions. Maybe abi3 does not give them the access they need? Maybe it does but a coin flip decided otherwise? IDK.

The combination of using a stable ABI and a per-version ABI causes the issue.

There is no mechanism for an abi3-using library to require its dependencies to “be binary packages”. You can always run into some library that needs to be built. Many trivial libraries are of that kind, either because they’re pure Python, or because their build from source is so simple.

OpenCV can only require some numpy 2.x that isn’t from the future, so <2.3.0. If there were a more flexible mechanism, it could have required “some numpy built for Python 3.14”.

The opposite of this flexibility is what NVIDIA does. Everyone has to depend on a specific minor version of CUDA. You’d have to coordinate every package’s version, or require maintainers to build multiple versions of their library tagged with CUDA versions in addition to their own version, because as soon as you update CUDA, every library depending on it has to be changed/recompiled too. This forum is full of threads about which CUDA version goes with which OpenCV version and why oh why OpenCV (even just the source) isn’t yet compatible with the newest CUDA that was released the night before.

Dependency resolution generally works better if the user is made to compile all their libraries. Then there is no ABI issue because there were no binaries to be incompatible against. It’s only an API issue, i.e. source code, which is much more flexible.

And that is what you ran into. The install tried to build numpy. That failed.

You can choose what you call the issue here: stable ABI opening the door time travel paradoxes, or numpy 2.2.6’s failure to build against Python 3.14 (on your system), or python’s dependency declaration language needing to evolve some more.