0

I'm trying to pip install this lib elasticdeform 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? :)

Janikas
  • 418
  • 1
  • 8
  • Have you tried building from source? Once your build finishes, trying installing with pip. –  Jul 21 '22 at 07:34
  • Hi, @Murali how can I do it? – Janikas Jul 21 '22 at 10:42
  • have a look at this answer. https://stackoverflow.com/questions/1471994/what-is-setup-py Make sure you set the path for all libraries –  Jul 21 '22 at 10:45
  • So I need to download the source code and then `pip install . `? – Janikas Jul 21 '22 at 11:12
  • 1
    yes, first try building it by ```python setup.py build ``` and then install using pip with ```pip install . ``` –  Jul 21 '22 at 12:55
  • @Murali I tried to do `python setup.py build`but the error persists. `elasticdeform/_deform_grid.c:37:44: error: use of undeclared identifier 'NPY_ARRAY_UPDATEIFCOPY'` – Janikas Jul 21 '22 at 16:28

1 Answers1

0

Fixed it with the help of @Murali!

First download the source code from here

Then open file _deform_grid.c and replace every NPY_ARRAY_UPDATEIFCOPY with NPY_ARRAY_WRITEBACKIFCOPY.

Finally just do:

>>> cd elasticdeform
>>> python setup.py build
>>> pip install .
Janikas
  • 418
  • 1
  • 8