Closed
Description
I'm trying to manually build a wheel from source. My Python version is 3.13. When I run pip install .
, I see the following error:
Traceback (most recent call last):
File "C:\Users\anguu\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
main()
~~~~^^
File "C:\Users\anguu\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\anguu\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 112, in get_requires_for_build_wheel
backend = _build_backend()
File "C:\Users\anguu\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 77, in _build_backend
obj = import_module(mod_path)
File "C:\Users\anguu\AppData\Local\Programs\Python\Python313\Lib\importlib\__init__.py", line 88, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 1022, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "C:\Users\anguu\AppData\Local\Temp\pip-build-env-jll306wz\overlay\Lib\site-packages\setuptools\__init__.py", line 16, in <module>
import setuptools.version
File "C:\Users\anguu\AppData\Local\Temp\pip-build-env-jll306wz\overlay\Lib\site-packages\setuptools\version.py", line 1, in <module>
import pkg_resources
File "C:\Users\anguu\AppData\Local\Temp\pip-build-env-jll306wz\overlay\Lib\site-packages\pkg_resources\__init__.py", line 2172, in <module>
register_finder(pkgutil.ImpImporter, find_on_path)
^^^^^^^^^^^^^^^^^^^
AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
I did some search and found that it may be due to the removal of deprecated ImpImporter
since Python 3.12 (https://stackoverflow.com/questions/77364550/attributeerror-module-pkgutil-has-no-attribute-impimporter-did-you-mean).
One possible fix is to update setuptools
, so I changed the build dependencies specified in pyproject.toml
and it worked.
[build-system]
requires = [
"cmake>=3.1",
"numpy==1.13.3; python_version=='3.6' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
"numpy==1.17.0; python_version=='3.7' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
"numpy==1.17.5; python_version=='3.8' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
"numpy==1.19.3; python_version<'3.9' and sys_platform == 'linux' and platform_machine == 'aarch64'",
"numpy==1.21.0; python_version<'3.9' and sys_platform == 'darwin' and platform_machine == 'arm64'",
"numpy>=2.0.0; python_version>='3.9'",
"pip",
"scikit-build>=0.14.0",
"setuptools", # <----- I removed the version "==59.2.0"
]
However, changing the version of setuptools
may cause unexpected affects. Could you please investigate this bug and publish an official fix?
Issue submission checklist
- This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)I have read the README of this repository and understand that this repository provides only an automated build toolchain for OpenCV Python packages (there is no actual OpenCV code here)The issue is related to the build scripts in this repository, to the pre-built binaries or is a feature request (such as "please enable this additional dependency")I'm using the latest version of
opencv-python
Activity
patchmeifyoucan commentedon Dec 9, 2024
I am also interested in using OpenCV with Python 3.13, especially the free-threaded 3.13t builds. What is the current status of support and the general agenda to support the free-threaded builds?
xbkaishui commentedon Dec 11, 2024
agree +1, any update on this
cpatulea commentedon Dec 14, 2024
I was using Home Assistant + OpenCV last year. This year I updated OpenCV to the latest version, and got the surprise that they dropped OpenCV (home-assistant/core#94617). The developers had tried to update OpenCV version during the Python 3.11 update, but failed and reverted (home-assistant/core#91802). The state today is that Home Assistant uses Python 3.13, and the wheel build still fails with the 'pkgutil.ImpImporter' error. Repro in the Home Assistant build environment:
I used to have a very simple image processing script that reads from a phone camera, runs some simple OpenCV operations, and provides data to Home Assistant, and for now I don't see any way to get my script running working again.
cpatulea commentedon Dec 14, 2024
This pull request looks related: #1061
cpatulea commentedon Dec 14, 2024
More PR related to 3.12 / setuputils: #1012
cpatulea commentedon Dec 14, 2024
And 3.12 related issue: #988
asmorkalov commentedon Jan 15, 2025
Fixed in #1061
cpatulea commentedon Jan 27, 2025
Confirming it built successfully, inside HomeAssistant Python 3.13 environment: