opencv-python icon indicating copy to clipboard operation
opencv-python copied to clipboard

Incompatible setuptools==59.2.0 with Python 3.12 due to pkgutil.ImpImporter removal for version 84.

Open ramnathnayak-ibm opened this issue 8 months ago • 0 comments

Description

When attempting to install opencv-python-headless for the version 4.10.0.84 or 84 using pip install . on Python 3.12 (specifically tested on ppc64le architecture), the installation fails with the following error:

  File "E:\dev\py\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
            main()
          File "E:\dev\py\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 "E:\dev\py\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 112, in get_requires_for_build_wheel
            backend = _build_backend()
                      ^^^^^^^^^^^^^^^^
          File "E:\dev\py\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 77, in _build_backend
            obj = import_module(mod_path)
                  ^^^^^^^^^^^^^^^^^^^^^^^
          File "E:\dev\py\Lib\importlib\__init__.py", line 90, in import_module
            return _bootstrap._gcd_import(name[level:], package, level)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "<frozen importlib._bootstrap>", line 1293, in _gcd_import
          File "<frozen importlib._bootstrap>", line 1266, in _find_and_load
          File "<frozen importlib._bootstrap>", line 1216, in _find_and_load_unlocked
          File "<frozen importlib._bootstrap>", line 400, in _call_with_frames_removed
          File "<frozen importlib._bootstrap>", line 1293, in _gcd_import
          File "<frozen importlib._bootstrap>", line 1266, in _find_and_load
          File "<frozen importlib._bootstrap>", line 1237, in _find_and_load_unlocked
          File "<frozen importlib._bootstrap>", line 841, in _load_unlocked
          File "<frozen importlib._bootstrap_external>", line 994, in exec_module
          File "<frozen importlib._bootstrap>", line 400, in _call_with_frames_removed
          File "C:\Users\shikingram\AppData\Local\Temp\pip-build-env-pk9ws81z\overlay\Lib\site-packages\setuptools\__init__.py", line 16, in <module>
            import setuptools.version
          File "C:\Users\shikingram\AppData\Local\Temp\pip-build-env-pk9ws81z\overlay\Lib\site-packages\setuptools\version.py", line 1, in <module>
            import pkg_resources
          File "C:\Users\shikingram\AppData\Local\Temp\pip-build-env-pk9ws81z\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

This is due to setuptools==59.2.0 relying on pkgutil.ImpImporter, which has been removed in Python 3.12 (Python 3.12 changelog).

Reproduction

  1. Set up a Python 3.12 virtual environment
  2. Run pip install . in the opencv-python-headless source directory for the version 84.
  3. Build fails due to incompatible setuptools version

Diagnosis

Older versions (e.g. 84) of the project set:

requires = ["setuptools==59.2.0"]

In the newer version i.e. 86 this is taken care of:

requires = ["setuptools<70.0.0; python_version>='3.12'"]

Would you like me to check if an issue or PR already exists for this, or help prepare a PR?

ramnathnayak-ibm avatar Apr 28 '25 05:04 ramnathnayak-ibm