1

Without python3.13 free-threading, cv2 importing numpy is fine. But when python3.13 free-threading is turned on, when cv2 tries to import numpy, numpy gives this error:

ImportError: Error importing numpy: you should not try to import numpy from
    its source directory; please exit the numpy source tree, and relaunch
    your python interpreter from there.

Does this mean cv2 and python3.13 free-threading are not compatible? I'm relatively new to cv2, python3.13 and threading :)

1 Answer 1

1

Starting with the 3.13 release, CPython has experimental support for a build of Python called free threading where the global interpreter lock (GIL) is disabled.

[...]

The free-threaded mode is experimental and work is ongoing to improve it: expect some bugs and a substantial single-threaded performance hit.

(From: https://docs.python.org/3/howto/free-threading-python.html. Emphasis mine.)

I think that counts as "some bugs".

You were right to try this. That's why they're offering this mode now, for users to test with all the things they care about.

You could file issues about this with the Python, OpenCV, and Numpy projects. Then they will know to investigate and work on this.

CPython (the canonical C Python implementation) tracks issues there:

https://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aopen%20label%3Atopic-free-threading

It looks like pandas also has trouble importing numpy:

https://github.com/python/cpython/issues/120653

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.