scikit-tda / ripser.py

A Lean Persistent Homology Library for Python
http://ripser.scikit-tda.org
Other
276 stars 61 forks source link

Failed to build ripser, error: subprocess-exited-with-error #142

Closed HapeFs closed 2 years ago

HapeFs commented 2 years ago

Hello,

I am trying to install ripser in a virtual environment using pipenv. However when I try to install it I get the following error:

 error: subprocess-exited-with-error

  × Building wheel for ripser (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [152 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.10
      creating build/lib.linux-x86_64-3.10/ripser
      copying ripser/ripser.py -> build/lib.linux-x86_64-3.10/ripser
      copying ripser/_version.py -> build/lib.linux-x86_64-3.10/ripser
      copying ripser/__init__.py -> build/lib.linux-x86_64-3.10/ripser
      warning: build_py: byte-compiling is disabled, skipping.

      running build_ext
      building 'pyRipser' extension
      creating build/temp.linux-x86_64-3.10
      creating build/temp.linux-x86_64-3.10/ripser
      gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -flto=auto -ffat-lto-objects -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -flto=auto -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -flto=auto -fPIC -DUSE_COEFFICIENTS=1 -DNDEBUG=1 -DASSEMBLE_REDUCTION_MATRIX=1 -I./ripser -I/home/swag/.local/share/virtualenvs/TDA-2Jg5I4oP/include -I/usr/include/python3.10 -I/tmp/pip-build-env-fr00vfej/overlay/lib/python3.10/site-packages/numpy/core/include -c ripser/pyRipser.cpp -o build/temp.linux-x86_64-3.10/ripser/pyRipser.o -Ofast -D_hypot=hypot -std=c++11
      In file included from /tmp/pip-build-env-fr00vfej/overlay/lib/python3.10/site-packages/numpy/core/include/numpy/ndarraytypes.h:1960,
                       from /tmp/pip-build-env-fr00vfej/overlay/lib/python3.10/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                       from /tmp/pip-build-env-fr00vfej/overlay/lib/python3.10/site-packages/numpy/core/include/numpy/arrayobject.h:5,
                       from ripser/pyRipser.cpp:739:
      /tmp/pip-build-env-fr00vfej/overlay/lib/python3.10/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
         17 | #warning "Using deprecated NumPy API, disable it with " \
            |  ^~~~~~~
      In file included from ripser/pyRipser.cpp:752:
      ripser/ripser.cpp:163:13: warning: attribute ignored in declaration of ‘struct entry_t’ [-Wattributes]
        163 | PACK(struct entry_t {
            |             ^~~~~~~
      ripser/ripser.cpp:160:49: note: in definition of macro ‘PACK’
        160 | #define PACK( ... ) __attribute__((__packed__)) __VA_ARGS__
            |                                                 ^~~~~~~~~~~
      ripser/ripser.cpp:163:13: note: attribute for ‘struct entry_t’ must follow the ‘struct’ keyword
        163 | PACK(struct entry_t {
            |             ^~~~~~~
      ripser/ripser.cpp:160:49: note: in definition of macro ‘PACK’
        160 | #define PACK( ... ) __attribute__((__packed__)) __VA_ARGS__
            |                                                 ^~~~~~~~~~~
      ripser/ripser.cpp: In member function ‘void ripser<DistanceMatrix>::compute_dim_0_pairs(std::vector<std::pair<float, long int> >&, std::vector<std::pair<float, long int> >&)’:
      ripser/ripser.cpp:707:26: error: ‘numeric_limits’ is not a member of ‘std’
        707 |                     std::numeric_limits<value_t>::infinity());
            |                          ^~~~~~~~~~~~~~
      ripser/ripser.cpp:707:48: error: expected primary-expression before ‘>’ token
        707 |                     std::numeric_limits<value_t>::infinity());
            |                                                ^
      ripser/ripser.cpp:707:51: error: ‘::infinity’ has not been declared; did you mean ‘isfinite’?
        707 |                     std::numeric_limits<value_t>::infinity());
            |                                                   ^~~~~~~~
            |                                                   isfinite
      ripser/ripser.cpp: In member function ‘void ripser<DistanceMatrix>::compute_pairs(std::vector<std::pair<float, long int> >&, ripser<DistanceMatrix>::entry_hash_map&, index_t)’:
      ripser/ripser.cpp:923:30: error: ‘numeric_limits’ is not a member of ‘std’
        923 |                         std::numeric_limits<value_t>::infinity());
 ripser/ripser.cpp:923:55: error: ‘::infinity’ has not been declared; did you mean ‘isfinite’?
        923 |                         std::numeric_limits<value_t>::infinity());
            |                                                       ^~~~~~~~
            |                                                       isfinite
      ripser/ripser.cpp: In function ‘ripserResults rips_dm(float*, int, int, int, float, int)’:
      ripser/ripser.cpp:1146:24: error: ‘numeric_limits’ is not a member of ‘std’
       1146 |     value_t min = std::numeric_limits<value_t>::infinity(),
            |                        ^~~~~~~~~~~~~~
      ripser/ripser.cpp:1146:46: error: expected primary-expression before ‘>’ token
       1146 |     value_t min = std::numeric_limits<value_t>::infinity(),
            |                                              ^
      ripser/ripser.cpp:1146:49: error: ‘::infinity’ has not been declared; did you mean ‘isfinite’?
       1146 |     value_t min = std::numeric_limits<value_t>::infinity(),
            |                                                 ^~~~~~~~
            |                                                 isfinite
      ripser/ripser.cpp:1153:27: error: ‘numeric_limits’ is not a member of ‘std’
       1153 |     if (threshold == std::numeric_limits<value_t>::max() ||
            |                           ^~~~~~~~~~~~~~
      ripser/ripser.cpp:1153:49: error: expected primary-expression before ‘>’ token
       1153 |     if (threshold == std::numeric_limits<value_t>::max() ||
            |                                                 ^
      ripser/ripser.cpp:1153:52: error: ‘::max’ has not been declared; did you mean ‘std::max’?
       1153 |     if (threshold == std::numeric_limits<value_t>::max() ||
            |                                                    ^~~
            |                                                    std::max
      In file included from /usr/include/c++/11.2.0/algorithm:62,
                       from ripser/ripser.cpp:41,
                       from ripser/pyRipser.cpp:752:
      /usr/include/c++/11.2.0/bits/stl_algo.h:3467:5: note: ‘std::max’ declared here
       3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
            |     ^~~
      In file included from ripser/pyRipser.cpp:752:
      ripser/ripser.cpp:1154:27: error: ‘numeric_limits’ is not a member of ‘std’
       1154 |         threshold == std::numeric_limits<value_t>::infinity()) {
            |                           ^~~~~~~~~~~~~~
      ripser/ripser.cpp:1154:49: error: expected primary-expression before ‘>’ token
       1154 |         threshold == std::numeric_limits<value_t>::infinity()) {
            |                                                 ^
      ripser/ripser.cpp:1154:52: error: ‘::infinity’ has not been declared; did you mean ‘isfinite’?
       1154 |         threshold == std::numeric_limits<value_t>::infinity()) {
            |                                                    ^~~~~~~~
            |                                                    isfinite
      ripser/ripser.cpp:1155:41: error: ‘numeric_limits’ is not a member of ‘std’
       1155 |         value_t enclosing_radius = std::numeric_limits<value_t>::infinity();
            |                                         ^~~~~~~~~~~~~~
      ripser/ripser.cpp:1155:63: error: expected primary-expression before ‘>’ token
       1155 |         value_t enclosing_radius = std::numeric_limits<value_t>::infinity();
            |                                                               ^
      ripser/ripser.cpp:1155:66: error: ‘::infinity’ has not been declared; did you mean ‘isfinite’?
       1155 |         value_t enclosing_radius = std::numeric_limits<value_t>::infinity();
            |                                                                  ^~~~~~~~
            |                                                                  isfinite
      ripser/ripser.cpp:1157:33: error: ‘numeric_limits’ is not a member of ‘std’
       1157 |             value_t r_i = -std::numeric_limits<value_t>::infinity();
 ripser/ripser.cpp:923:55: error: ‘::infinity’ has not been declared; did you mean ‘isfinite’?
        923 |                         std::numeric_limits<value_t>::infinity());
            |                                                       ^~~~~~~~
            |                                                       isfinite
      ripser/ripser.cpp: In function ‘ripserResults rips_dm(float*, int, int, int, float, int)’:
      ripser/ripser.cpp:1146:24: error: ‘numeric_limits’ is not a member of ‘std’
       1146 |     value_t min = std::numeric_limits<value_t>::infinity(),
            |                        ^~~~~~~~~~~~~~
      ripser/ripser.cpp:1146:46: error: expected primary-expression before ‘>’ token
       1146 |     value_t min = std::numeric_limits<value_t>::infinity(),
            |                                              ^
      ripser/ripser.cpp:1146:49: error: ‘::infinity’ has not been declared; did you mean ‘isfinite’?
       1146 |     value_t min = std::numeric_limits<value_t>::infinity(),
            |                                                 ^~~~~~~~
            |                                                 isfinite
      ripser/ripser.cpp:1153:27: error: ‘numeric_limits’ is not a member of ‘std’
       1153 |     if (threshold == std::numeric_limits<value_t>::max() ||
            |                           ^~~~~~~~~~~~~~
      ripser/ripser.cpp:1153:49: error: expected primary-expression before ‘>’ token
       1153 |     if (threshold == std::numeric_limits<value_t>::max() ||
            |                                                 ^
      ripser/ripser.cpp:1153:52: error: ‘::max’ has not been declared; did you mean ‘std::max’?
       1153 |     if (threshold == std::numeric_limits<value_t>::max() ||
            |                                                    ^~~
            |                                                    std::max
      In file included from /usr/include/c++/11.2.0/algorithm:62,
                       from ripser/ripser.cpp:41,
                       from ripser/pyRipser.cpp:752:
      /usr/include/c++/11.2.0/bits/stl_algo.h:3467:5: note: ‘std::max’ declared here
       3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
            |     ^~~
      In file included from ripser/pyRipser.cpp:752:
      ripser/ripser.cpp:1154:27: error: ‘numeric_limits’ is not a member of ‘std’
       1154 |         threshold == std::numeric_limits<value_t>::infinity()) {
            |                           ^~~~~~~~~~~~~~
      ripser/ripser.cpp:1154:49: error: expected primary-expression before ‘>’ token
       1154 |         threshold == std::numeric_limits<value_t>::infinity()) {
            |                                                 ^
      ripser/ripser.cpp:1154:52: error: ‘::infinity’ has not been declared; did you mean ‘isfinite’?
       1154 |         threshold == std::numeric_limits<value_t>::infinity()) {
            |                                                    ^~~~~~~~
            |                                                    isfinite
      ripser/ripser.cpp:1155:41: error: ‘numeric_limits’ is not a member of ‘std’
       1155 |         value_t enclosing_radius = std::numeric_limits<value_t>::infinity();
            |                                         ^~~~~~~~~~~~~~
      ripser/ripser.cpp:1155:63: error: expected primary-expression before ‘>’ token
       1155 |         value_t enclosing_radius = std::numeric_limits<value_t>::infinity();
            |                                                               ^
      ripser/ripser.cpp:1155:66: error: ‘::infinity’ has not been declared; did you mean ‘isfinite’?
       1155 |         value_t enclosing_radius = std::numeric_limits<value_t>::infinity();
            |                                                                  ^~~~~~~~
            |                                                                  isfinite
      ripser/ripser.cpp:1157:33: error: ‘numeric_limits’ is not a member of ‘std’
       1157 |             value_t r_i = -std::numeric_limits<value_t>::infinity();
  ripser/ripser.cpp:1157:55: error: expected primary-expression before ‘>’ token
       1157 |             value_t r_i = -std::numeric_limits<value_t>::infinity();
            |                                                       ^
      ripser/ripser.cpp:1157:58: error: ‘::infinity’ has not been declared; did you mean ‘isfinite’?
       1157 |             value_t r_i = -std::numeric_limits<value_t>::infinity();
            |                                                          ^~~~~~~~
            |                                                          isfinite
      ripser/ripser.cpp:1167:9: error: ‘max’ was not declared in this scope; did you mean ‘std::max’?
       1167 |         max = std::max(max, d);
            |         ^~~
            |         std::max
      In file included from /usr/include/c++/11.2.0/algorithm:62,
                       from ripser/ripser.cpp:41,
                       from ripser/pyRipser.cpp:752:
      /usr/include/c++/11.2.0/bits/stl_algo.h:3467:5: note: ‘std::max’ declared here
       3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
            |     ^~~
      In file included from ripser/pyRipser.cpp:752:
      ripser/ripser.cpp:1168:9: error: ‘max_finite’ was not declared in this scope; did you mean ‘isfinite’?
       1168 |         max_finite = d != std::numeric_limits<value_t>::infinity()
            |         ^~~~~~~~~~
            |         isfinite
      ripser/ripser.cpp:1168:32: error: ‘numeric_limits’ is not a member of ‘std’
       1168 |         max_finite = d != std::numeric_limits<value_t>::infinity()
            |                                ^~~~~~~~~~~~~~
      ripser/ripser.cpp:1168:54: error: expected primary-expression before ‘>’ token
       1168 |         max_finite = d != std::numeric_limits<value_t>::infinity()
            |                                                      ^
      ripser/ripser.cpp:1168:57: error: ‘::infinity’ has not been declared; did you mean ‘isfinite’?
       1168 |         max_finite = d != std::numeric_limits<value_t>::infinity()
            |                                                         ^~~~~~~~
            |                                                         isfinite
      ripser/ripser.cpp:1176:22: error: ‘max’ was not declared in this scope; did you mean ‘std::max’?
       1176 |     if (threshold >= max) {
            |                      ^~~
            |                      std::max
      In file included from /usr/include/c++/11.2.0/algorithm:62,
                       from ripser/ripser.cpp:41,
                       from ripser/pyRipser.cpp:752:
      /usr/include/c++/11.2.0/bits/stl_algo.h:3467:5: note: ‘std::max’ declared here
       3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
            |     ^~~
      error: command '/usr/bin/gcc' 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 ripser
ERROR: Could not build wheels for ripser, which is required to install pyproject.toml-based projects

✘ Installation Failed

I tried installing it in my root environment however then I get an error along the lines of this thread https://github.com/scikit-tda/ripser.py/issues/47 When I try the presented solution by just installing it via git the package asks for root access which I am always hesitant to give for python code. I am running python 3.10.3 on Arch Linux.

HapeFs commented 2 years ago

I have since solved the issue with help from a previous post on this page.

If one adds

#include <limits>

in the file ripser.cpp the installation should go correctly then.

lizliz commented 2 years ago

I was able to successfully install using this trick but then can't import in python. I get the following in

In [1]: import ripser
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-0f76cfc72a4f> in <module>
----> 1 import ripser

~/Programs/ripser.py/ripser/__init__.py in <module>
----> 1 from .ripser import *
      2 
      3 from ._version import __version__

~/Programs/ripser.py/ripser/ripser.py in <module>
     32 from sklearn.metrics.pairwise import pairwise_distances
     33 
---> 34 from pyRipser import doRipsFiltrationDM as DRFDM
     35 from pyRipser import doRipsFiltrationDMSparse as DRFDMSparse
     36 

ImportError: /home/liz/Programs/anaconda3/lib/python3.9/site-packages/pyRipser.cpython-39-x86_64-linux-gnu.so: undefined symbol: _ZSt28__throw_bad_array_new_lengthv
ctralie commented 2 years ago

Wow this is a pain! Just wanted to acknowledge that I got this, though it's a rough time in the semester for me and I won't be able to fix it right away. @sauln Can you have a look at this?

On Tue, Apr 26, 2022 at 3:56 PM Elizabeth Munch @.***> wrote:

I was able to successfully install using this trick but then can't import in python. I get the following in

In [1]: import ripser

ImportError Traceback (most recent call last)

in ----> 1 import ripser ~/Programs/ripser.py/ripser/__init__.py in ----> 1 from .ripser import * 2 3 from ._version import __version__ ~/Programs/ripser.py/ripser/ripser.py in 32 from sklearn.metrics.pairwise import pairwise_distances 33 ---> 34 from pyRipser import doRipsFiltrationDM as DRFDM 35 from pyRipser import doRipsFiltrationDMSparse as DRFDMSparse 36 ImportError: /home/liz/Programs/anaconda3/lib/python3.9/site-packages/pyRipser.cpython-39-x86_64-linux-gnu.so: undefined symbol: _ZSt28__throw_bad_array_new_lengthv — Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
redet-G commented 2 years ago

I created a new environment with python 3.8 and the installation was successful but then I cannot import it either. ModuleNotFoundError: No module named 'ripser'

ismailguzel commented 2 years ago

I tried to fix version problems with a new environment for Topological Data Analysis tools which has a lot of packages. I hope it will help the version issues. YML file is here

ctralie commented 2 years ago

Fixed in newest release