gvtulder / elasticdeform

Differentiable elastic deformations for N-dimensional images (Python, SciPy, NumPy, TensorFlow, PyTorch).
Other
183 stars 25 forks source link

Installing elasticdeform on mac m1 | error: use of undeclared identifier 'NPY_ARRAY_UPDATEIFCOPY' #16

Closed joaolcguerreiro closed 1 year ago

joaolcguerreiro commented 2 years ago

I'm trying to pip install this lib but I'm getting the following error:

Collecting elasticdeform
  Using cached elasticdeform-0.4.9.tar.gz (33 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: numpy in /Users/joaoguerreiro/opt/anaconda3/envs/thesis-2/lib/python3.9/site-packages (from elasticdeform) (1.23.0)
Requirement already satisfied: scipy in /Users/joaoguerreiro/opt/anaconda3/envs/thesis-2/lib/python3.9/site-packages (from elasticdeform) (1.8.1)
Building wheels for collected packages: elasticdeform
  Building wheel for elasticdeform (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [20 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-11.0-arm64-cpython-39
      creating build/lib.macosx-11.0-arm64-cpython-39/elasticdeform
      copying elasticdeform/tf.py -> build/lib.macosx-11.0-arm64-cpython-39/elasticdeform
      copying elasticdeform/__init__.py -> build/lib.macosx-11.0-arm64-cpython-39/elasticdeform
      copying elasticdeform/torch.py -> build/lib.macosx-11.0-arm64-cpython-39/elasticdeform
      copying elasticdeform/deform_grid.py -> build/lib.macosx-11.0-arm64-cpython-39/elasticdeform
      running build_ext
      building 'elasticdeform._deform_grid' extension
      creating build/temp.macosx-11.0-arm64-cpython-39
      creating build/temp.macosx-11.0-arm64-cpython-39/elasticdeform
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/joaoguerreiro/opt/anaconda3/envs/thesis-2/include -arch arm64 -fPIC -O2 -isystem /Users/joaoguerreiro/opt/anaconda3/envs/thesis-2/include -arch arm64 -Ielasticdeform -I/Users/joaoguerreiro/opt/anaconda3/envs/thesis-2/include/python3.9 -I/Users/joaoguerreiro/opt/anaconda3/envs/thesis-2/lib/python3.9/site-packages/numpy/core/include -c elasticdeform/_deform_grid.c -o build/temp.macosx-11.0-arm64-cpython-39/elasticdeform/_deform_grid.o
      elasticdeform/_deform_grid.c:37:44: error: use of undeclared identifier 'NPY_ARRAY_UPDATEIFCOPY'
              int flags = NPY_ARRAY_BEHAVED_NS | NPY_ARRAY_UPDATEIFCOPY;
                                                 ^
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for elasticdeform
  Running setup.py clean for elasticdeform
Failed to build elasticdeform
Installing collected packages: elasticdeform
  Running setup.py install for elasticdeform ... error
  error: subprocess-exited-with-error

  × Running setup.py install for elasticdeform did not run successfully.
  │ exit code: 1
  ╰─> [22 lines of output]
      running install
      /Users/joaoguerreiro/opt/anaconda3/envs/thesis-2/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.macosx-11.0-arm64-cpython-39
      creating build/lib.macosx-11.0-arm64-cpython-39/elasticdeform
      copying elasticdeform/tf.py -> build/lib.macosx-11.0-arm64-cpython-39/elasticdeform
      copying elasticdeform/__init__.py -> build/lib.macosx-11.0-arm64-cpython-39/elasticdeform
      copying elasticdeform/torch.py -> build/lib.macosx-11.0-arm64-cpython-39/elasticdeform
      copying elasticdeform/deform_grid.py -> build/lib.macosx-11.0-arm64-cpython-39/elasticdeform
      running build_ext
      building 'elasticdeform._deform_grid' extension
      creating build/temp.macosx-11.0-arm64-cpython-39
      creating build/temp.macosx-11.0-arm64-cpython-39/elasticdeform
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/joaoguerreiro/opt/anaconda3/envs/thesis-2/include -arch arm64 -fPIC -O2 -isystem /Users/joaoguerreiro/opt/anaconda3/envs/thesis-2/include -arch arm64 -Ielasticdeform -I/Users/joaoguerreiro/opt/anaconda3/envs/thesis-2/include/python3.9 -I/Users/joaoguerreiro/opt/anaconda3/envs/thesis-2/lib/python3.9/site-packages/numpy/core/include -c elasticdeform/_deform_grid.c -o build/temp.macosx-11.0-arm64-cpython-39/elasticdeform/_deform_grid.o
      elasticdeform/_deform_grid.c:37:44: error: use of undeclared identifier 'NPY_ARRAY_UPDATEIFCOPY'
              int flags = NPY_ARRAY_BEHAVED_NS | NPY_ARRAY_UPDATEIFCOPY;
                                                 ^
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]

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

× Encountered error while trying to install package.
╰─> elasticdeform

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

Looking at it I can understand the problem is because of NPY_ARRAY_UPDATEIFCOPY...

I have a macbook pro m1. I'm trying to install this on python 3 in a conda environment. I tried to export NPY_ARRAY_UPDATEIFCOPY=true but it did not work. Is there any work around? :)

joaolcguerreiro commented 2 years ago

fixed it! follow: https://stackoverflow.com/questions/73060279/installing-elasticdeform-on-mac-m1-error-use-of-undeclared-identifier-npy-ar/73069804#73069804

gvtulder commented 1 year ago

Should be fixed now in the pypi package as well. Thanks!