oracle / graalpython

A Python 3 implementation built on GraalVM
Other
1.17k stars 101 forks source link

cant install opencv #387

Closed ACCLE123 closed 4 months ago

ACCLE123 commented 4 months ago

I am using a Mac M1 computer. I have already installed xcode-select. When I use pip from GraalPy to download opencv, it reports an error.

how can i fix it

(venv) (base) yangqi@yq pythondemo2 % pip install opencv-python
Collecting opencv-python
  Using cached opencv-python-4.9.0.80.tar.gz (92.9 MB)
auto-patching C API usages in /private/var/folders/5g/8lx8wksx7hlb6vdwbbyjbyxc0000gn/T/pip-install-mhv_os1f/opencv-python_eb1754d446c64d2a8de2b9ce8a0e7af7/opencv/modules/python/src2/pycompat.hpp
auto-patching C API usages in /private/var/folders/5g/8lx8wksx7hlb6vdwbbyjbyxc0000gn/T/pip-install-mhv_os1f/opencv-python_eb1754d446c64d2a8de2b9ce8a0e7af7/opencv/modules/python/src2/cv2_convert.cpp
Looking for GraalPy patches for opencv-python
  Installing build dependencies ... error
  error: subprocess-exited-with-error

  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [2322 lines of output]
      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.11"' don't match your environment
      Collecting cmake>=3.1
        Using cached cmake-3.28.3-py2.py3-none-macosx_10_10_universal2.macosx_10_10_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl (48.5 MB)
      Collecting numpy==1.21.4
        Using cached numpy-1.21.4.zip (10.6 MB)
      auto-patching C API usages in /private/var/folders/5g/8lx8wksx7hlb6vdwbbyjbyxc0000gn/T/pip-install-7ayw8jfb/numpy_c7f6a24b2f42443dba9cf9be601116ca/numpy/core/include/numpy/ndarrayobject.h
     ...
      Looking for GraalPy patches for numpy
      We have patches to make this package work on GraalVM for some version(s).
      If installing or running fails, consider using one of the versions that we have patches for:
      numpy == 1.16.4
      numpy == 1.19.5
      numpy == 1.21.6
      numpy == 1.22.4
      numpy == 1.23.4
      numpy == 1.23.1
      numpy == 1.23.5
        Installing build dependencies: started
        Installing build dependencies: finished with status 'done'
        Getting requirements to build wheel: started
        Getting requirements to build wheel: finished with status 'done'
        Preparing metadata (pyproject.toml): started
        Preparing metadata (pyproject.toml): finished with status 'done'
      Collecting pip
        Using cached pip-22.2.2-py3-none-any.whl (2.0 MB)
      Collecting scikit-build>=0.14.0
        Using cached scikit_build-0.17.6-py3-none-any.whl (84 kB)
      Collecting setuptools==59.2.0
        Using cached setuptools-59.2.0-py3-none-any.whl (952 kB)
      Collecting distro
        Using cached distro-1.9.0-py3-none-any.whl (20 kB)
      Collecting packaging
        Using cached packaging-23.2-py3-none-any.whl (53 kB)
      Collecting tomli
        Using cached tomli-2.0.1-py3-none-any.whl (12 kB)
      Collecting wheel>=0.32.0
        Using cached wheel-0.41.2-py3-none-any.whl (64 kB)
      Building wheels for collected packages: numpy
        Building wheel for numpy (pyproject.toml): started
        Building wheel for numpy (pyproject.toml): still running...
        Building wheel for numpy (pyproject.toml): still running...
        Building wheel for numpy (pyproject.toml): finished with status 'error'
        error: subprocess-exited-with-error

        × Building wheel for numpy (pyproject.toml) did not run successfully.
        │ exit code: 1
        ╰─> [2257 lines of output]
            /private/var/folders/5g/8lx8wksx7hlb6vdwbbyjbyxc0000gn/T/pip-install-7ayw8jfb/numpy_c7f6a24b2f42443dba9cf9be601116ca/setup.py:63: RuntimeWarning: NumPy 1.21.4 may not yet support Python 3.10.
              warnings.warn(
            Running from numpy source directory.
            Cythonizing sources
            Processing numpy/random/_bounded_integers.pxd.in

         ...

            compile options: '-Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/src/_simd -I/Users/yangqi/Code/demo1/pythondemo2/venv/include -I/Users/yangqi/.pyenv/versions/graalpy-23.1.0/include/python3.10 -Ibuild/src.darwin-23.1.0-arm64-3.10/numpy/core/src/common -Ibuild/src.darwin-23.1.0-arm64-3.10/numpy/core/src/npymath -c'
            extra options: '-Werror'
            CCompilerOpt.__init__[1701] : check requested baseline
            CCompilerOpt.feature_test[1466] : testing feature 'NEON_FP16' with flags ()
            C compiler: gcc -DNDEBUG -D_GNU_SOURCE=1 -I/opt/homebrew/opt/llvm/include -fPIC

         ...
            numpy/core/src/npymath/npy_math_internal.h.src:558:21: warning: incompatible pointer types passing 'npy_longdouble *' (aka 'double *') to parameter of type 'long double *' [-Wincompatible-pointer-types]
                return modfl(x, iptr);
                                ^~~~
            /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:395:52: note: passing argument to parameter here
            extern long double modfl(long double, long double *);
                                                               ^
            2 warnings generated.
            2 warnings generated.
            2 warnings generated.
            2 warnings generated.
            2 warnings generated.
            compiling C sources
            C compiler: gcc -DNDEBUG -D_GNU_SOURCE=1 -I/opt/homebrew/opt/llvm/include -fPIC
      ...
                    ^
            /Users/yangqi/.pyenv/versions/graalpy-23.1.0/include/python3.10/pyconfig.h:117:9: note: previous definition is here
            #define SIZEOF_OFF_T __SIZEOF_SIZE_T__
                    ^
            1 warning generated.
            2 warnings generated.

            ########### EXT COMPILER OPTIMIZATION ###########
            Platform      :
              Architecture: aarch64
              Compiler    : gcc

            CPU baseline  :
              Requested   : 'min'
              Enabled     : NEON NEON_FP16 NEON_VFPV4 ASIMD
              Flags       : none
              Extra checks: none

            CPU dispatch  :
              Requested   : 'max -xop -fma4'
              Enabled     : ASIMDHP ASIMDDP
              Generated   : none
            CCompilerOpt.cache_flush[809] : write cache to path -> /private/var/folders/5g/8lx8wksx7hlb6vdwbbyjbyxc0000gn/T/pip-install-7ayw8jfb/numpy_c7f6a24b2f42443dba9cf9be601116ca/build/temp.darwin-23.1.0-arm64-3.10/ccompiler_opt_cache_ext.py

            ########### CLIB COMPILER OPTIMIZATION ###########
            Platform      :
              Architecture: aarch64
              Compiler    : gcc

            CPU baseline  :
              Requested   : 'min'
              Enabled     : NEON NEON_FP16 NEON_VFPV4 ASIMD
              Flags       : none
              Extra checks: none

            CPU dispatch  :
              Requested   : 'max -xop -fma4'
              Enabled     : ASIMDHP ASIMDDP
              Generated   : none
            CCompilerOpt.cache_flush[809] : write cache to path -> /private/var/folders/5g/8lx8wksx7hlb6vdwbbyjbyxc0000gn/T/pip-install-7ayw8jfb/numpy_c7f6a24b2f42443dba9cf9be601116ca/build/temp.darwin-23.1.0-arm64-3.10/ccompiler_opt_cache_clib.py
            error: Command "gcc -DNDEBUG -D_GNU_SOURCE=1 -I/opt/homebrew/opt/llvm/include -fPIC -DNPY_INTERNAL_BUILD=1 -DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -DNO_ATLAS_INFO=3 -DHAVE_CBLAS -Ibuild/src.darwin-23.1.0-arm64-3.10/numpy/core/src/common -Ibuild/src.darwin-23.1.0-arm64-3.10/numpy/core/src/umath -Inumpy/core/include -Ibuild/src.darwin-23.1.0-arm64-3.10/numpy/core/include/numpy -Ibuild/src.darwin-23.1.0-arm64-3.10/numpy/distutils/include -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/src/_simd -I/Users/yangqi/Code/demo1/pythondemo2/venv/include -I/Users/yangqi/.pyenv/versions/graalpy-23.1.0/include/python3.10 -Ibuild/src.darwin-23.1.0-arm64-3.10/numpy/core/src/common -Ibuild/src.darwin-23.1.0-arm64-3.10/numpy/core/src/npymath -c build/src.darwin-23.1.0-arm64-3.10/numpy/core/src/multiarray/arraytypes.c -o build/temp.darwin-23.1.0-arm64-3.10/build/src.darwin-23.1.0-arm64-3.10/numpy/core/src/multiarray/arraytypes.o -MMD -MF build/temp.darwin-23.1.0-arm64-3.10/build/src.darwin-23.1.0-arm64-3.10/numpy/core/src/multiarray/arraytypes.o.d -I/System/Library/Frameworks/vecLib.framework/Headers" failed with exit status 1
            [end of output]

        note: This error originates from a subprocess, and is likely not a problem with pip.
        ERROR: Failed building wheel for numpy
      Failed to build numpy
      ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects
      [end of output]

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

× pip subprocess to install build dependencies 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.
msimacek commented 4 months ago

We were missing a patch for the specific version of numpy that opencv requests. It should be already fixed in master. On the released version, you should be able to work around the problem using:

pip install numpy scikit-build
pip install --no-build-isolation opencv-python