Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build from source python 3.12 fails #988

Open
4 tasks done
EnricoBeltramo opened this issue May 28, 2024 · 6 comments · May be fixed by #1012
Open
4 tasks done

Build from source python 3.12 fails #988

EnricoBeltramo opened this issue May 28, 2024 · 6 comments · May be fixed by #1012
Labels

Comments

@EnricoBeltramo
Copy link

EnricoBeltramo commented May 28, 2024

Expected behaviour

I tried to build the tag 80 in python 3.12, but build fails

Write here how did you expect the library to function.
correct build from source

Actual behaviour

Write here what went wrong.
install of some dependencies (i.e. numpy) fail with this error:
AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
the dependencies versions of numpy and setuptools are outdated and broken in python 3.12. Is it possible to use latest versions of those packages?

Steps to reproduce

  • example code: build from source as tutorial in main page
  • operating system: Ubuntu 22.04
  • architecture (e.g. x86): x86
  • opencv-python version: 80
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
@EnricoBeltramo
Copy link
Author

I already tried that and it didn't work.

@asmorkalov
Copy link
Collaborator

#992

@montmejat
Copy link

I'm also getting the same error with the latest merged updates:

Processing /home/aurelien/Projects/GitHub/opencv-python
  Running command pip subprocess to install build dependencies
  Ignoring numpy: markers 'python_version == "3.6" and platform_machine != "aarch64" and platform_machine != "arm64"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.7" and platform_machine != "aarch64" and platform_machine != "arm64"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.8" and platform_machine != "aarch64" and platform_machine != "arm64"' don't match your environment
  Ignoring numpy: markers 'python_version <= "3.9" and sys_platform == "linux" and platform_machine == "aarch64"' don't match your environment
  Ignoring numpy: markers 'python_version <= "3.9" and sys_platform == "darwin" and platform_machine == "arm64"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.9" and platform_machine != "aarch64" and platform_machine != "arm64"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.10" and platform_system != "Darwin"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.10" and platform_system == "Darwin"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.11"' don't match your environment
  Collecting cmake>=3.1
    Using cached cmake-3.29.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.1 kB)
  Collecting numpy>=1.26.4
    Using cached numpy-1.26.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB)
  Collecting pip
    Using cached pip-24.0-py3-none-any.whl.metadata (3.6 kB)
  Collecting scikit-build>=0.14.0
    Using cached scikit_build-0.17.6-py3-none-any.whl.metadata (14 kB)
  Collecting setuptools==59.2.0
    Using cached setuptools-59.2.0-py3-none-any.whl.metadata (5.0 kB)
  Collecting distro (from scikit-build>=0.14.0)
    Using cached distro-1.9.0-py3-none-any.whl.metadata (6.8 kB)
  Collecting packaging (from scikit-build>=0.14.0)
    Using cached packaging-24.1-py3-none-any.whl.metadata (3.2 kB)
  Collecting wheel>=0.32.0 (from scikit-build>=0.14.0)
    Using cached wheel-0.43.0-py3-none-any.whl.metadata (2.2 kB)
  Using cached setuptools-59.2.0-py3-none-any.whl (952 kB)
  Using cached cmake-3.29.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (26.7 MB)
  Using cached numpy-1.26.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.0 MB)
  Using cached pip-24.0-py3-none-any.whl (2.1 MB)
  Using cached scikit_build-0.17.6-py3-none-any.whl (84 kB)
  Using cached wheel-0.43.0-py3-none-any.whl (65 kB)
  Using cached distro-1.9.0-py3-none-any.whl (20 kB)
  Using cached packaging-24.1-py3-none-any.whl (53 kB)
  Installing collected packages: wheel, setuptools, pip, packaging, numpy, distro, cmake, scikit-build
  Successfully installed cmake-3.29.5 distro-1.9.0 numpy-1.26.4 packaging-24.1 pip-24.0 scikit-build-0.17.6 setuptools-59.2.0 wheel-0.43.0
  Installing build dependencies ... done
  Running command Getting requirements to build wheel
  Traceback (most recent call last):
    File "/home/aurelien/Projects/GitHub/opencv-python/.venv/lib64/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/home/aurelien/Projects/GitHub/opencv-python/.venv/lib64/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/aurelien/Projects/GitHub/opencv-python/.venv/lib64/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 112, in get_requires_for_build_wheel
      backend = _build_backend()
                ^^^^^^^^^^^^^^^^
    File "/home/aurelien/Projects/GitHub/opencv-python/.venv/lib64/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 77, in _build_backend
      obj = import_module(mod_path)
            ^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib64/python3.12/importlib/__init__.py", line 90, 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 995, in exec_module
    File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
    File "/tmp/pip-build-env-who73wyv/overlay/lib/python3.12/site-packages/setuptools/__init__.py", line 16, in <module>
      import setuptools.version
    File "/tmp/pip-build-env-who73wyv/overlay/lib/python3.12/site-packages/setuptools/version.py", line 1, in <module>
      import pkg_resources
    File "/tmp/pip-build-env-who73wyv/overlay/lib/python3.12/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'?
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /home/aurelien/Projects/GitHub/opencv-python/.venv/bin/python /home/aurelien/Projects/GitHub/opencv-python/.venv/lib64/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py get_requires_for_build_wheel /tmp/tmp35dh4ua_
  cwd: /home/aurelien/Projects/GitHub/opencv-python
  Getting requirements to build wheel ... error
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

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

@zhanwenchen
Copy link

zhanwenchen commented Jun 12, 2024

I encountered the same problem while running pip wheel . --verbose |& tee install_opencv.log. It worked after removing the ==59.2.0" from the "setuptools==59.2.0" https://github.com/opencv/opencv-python/blob/4.x/pyproject.toml#L16.

@sibocw
Copy link

sibocw commented Jun 19, 2024

Thank you @zhanwenchen, I also encountered the same issue (even after following the StackOverflow answer above), and solved it the same way. I think the ==59.2.0 prevents pip from using the most up-to-date setuptools that has this API change addressed.

Is there a particular reason why there's such a strict requirement for setuptools? Can I make a PR to remove it (or change it to >=59.2.0)?

bryankaplan added a commit to bryankaplan/opencv-python that referenced this issue Jul 4, 2024
Currently, opencv-python fails to build under python 3.12. This patch
fixes that problem by permitting the use of any setuptools>=59.2.0,
rather than mandating that specific version.

This patch fixes opencv#988. See discussion there for details.

I have tested by successfully installing opencv-python.
@bryankaplan bryankaplan linked a pull request Jul 4, 2024 that will close this issue
bryankaplan added a commit to bryankaplan/opencv-python that referenced this issue Dec 15, 2024
Currently, opencv-python fails to build under python 3.12. This patch
fixes that problem by permitting the use of any setuptools>=59.2.0,
rather than mandating that specific version.

This patch fixes opencv#988. See discussion there for details.

I have tested by successfully installing opencv-python.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants