auto-sklearn: Exit code 1 while pip installing library

Describe the bug

Library not installing, while installing with pip install auto-sklearn

To Reproduce

Steps to reproduce the behavior:

  • Execute command pip install auto-sklearn (python 3.10)

Expected behavior

The library should have got installed

Actual behavior, stacktrace or logfile

Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [825 lines of output]
      <string>:17: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
      Partial import of sklearn during the build process.
      <string>:116: DeprecationWarning:
      
        `numpy.distutils` is deprecated since NumPy 1.23.0, as a result
        of the deprecation of `distutils` itself. It will be removed for
        Python >= 3.12. For older Python versions it will remain present.
        It is recommended to use `setuptools < 60.0` for those Python versions.
        For more details, see:
          https://numpy.org/devdocs/reference/distutils_status_migration.html  
Error compiling Cython file:
      ------------------------------------------------------------
      ...
              if n_used_bins <= 1:
                  free(cat_infos)
                  return
      
              qsort(cat_infos, n_used_bins, sizeof(categorical_info),
                    compare_cat_infos)
                    ^
      ------------------------------------------------------------

sklearn/ensemble/_hist_gradient_boosting/splitting.pyx:912:14: Cannot assign type 'int (const void *, const void *) except? -1 nogil' to 'int (*)(const void *, const void *) noexcept nogil'
      Traceback (most recent call last):
        File "/tmp/pip-build-env-at5n6u8u/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1325, in cythonize_one_helper
          return cythonize_one(*m)
        File "/tmp/pip-build-env-at5n6u8u/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1301, in cythonize_one
          raise CompileError(None, pyx_file)
      Cython.Compiler.Errors.CompileError: sklearn/ensemble/_hist_gradient_boosting/splitting.pyx
warning: sklearn/neighbors/_dist_metrics.pxd:77:67: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
              # determine number of levels in the tree, and from this
              # the number of nodes in the tree.  This results in leaf nodes
              # with numbers of points between leaf_size and 2 * leaf_size
              self.n_levels = int(
                  np.log2(fmax(1, (n_samples - 1) / self.leaf_size)) + 1)
              self.n_nodes = (2 ** self.n_levels) - 1
                                                  ^
      ------------------------------------------------------------
      
      sklearn/neighbors/_binary_tree.pxi:1079:44: Cannot assign type 'double' to 'ITYPE_t'
      Traceback (most recent call last):
        File "/tmp/pip-build-env-at5n6u8u/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1325, in cythonize_one_helper
          return cythonize_one(*m)
        File "/tmp/pip-build-env-at5n6u8u/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1301, in cythonize_one
          raise CompileError(None, pyx_file)
      Cython.Compiler.Errors.CompileError: sklearn/neighbors/_ball_tree.pyx
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          def __cinit__(self, int n_dimensions, int verbose):
              """Constructor."""
              # Parameters of the tree
              self.n_dimensions = n_dimensions
              self.verbose = verbose
              self.n_cells_per_cell = 2 ** self.n_dimensions
                                        ^
      ------------------------------------------------------------
      
      sklearn/neighbors/_quad_tree.pyx:60:34: Cannot assign type 'double' to 'SIZE_t'
      Traceback (most recent call last):
        File "/tmp/pip-build-env-at5n6u8u/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1325, in cythonize_one_helper
          return cythonize_one(*m)
        File "/tmp/pip-build-env-at5n6u8u/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1301, in cythonize_one
          raise CompileError(None, pyx_file)
      Cython.Compiler.Errors.CompileError: sklearn/neighbors/_quad_tree.pyx
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
              free_problem(problem)
              free_parameter(param)
              raise ValueError(error_msg)
      
          cdef BlasFunctions blas_functions
          blas_functions.dot = _dot[double]
                                   ^
      ------------------------------------------------------------
      
      sklearn/svm/_liblinear.pyx:55:29: Cannot assign type 'double (int, double *, int, double *, int) except * nogil' to 'dot_func'
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
              free_parameter(param)
              raise ValueError(error_msg)
      
          cdef BlasFunctions blas_functions
          blas_functions.dot = _dot[double]
          blas_functions.axpy = _axpy[double]
                                     ^
      ------------------------------------------------------------
      
      sklearn/svm/_liblinear.pyx:56:31: Cannot assign type 'void (int, double, double *, int, double *, int) except * nogil' to 'axpy_func'
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
              raise ValueError(error_msg)
      
          cdef BlasFunctions blas_functions
          blas_functions.dot = _dot[double]
          blas_functions.axpy = _axpy[double]
          blas_functions.scal = _scal[double]
                                     ^
      ------------------------------------------------------------
      
      sklearn/svm/_liblinear.pyx:57:31: Cannot assign type 'void (int, double, double *, int) except * nogil' to 'scal_func'
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
      
          cdef BlasFunctions blas_functions
          blas_functions.dot = _dot[double]
          blas_functions.axpy = _axpy[double]
          blas_functions.scal = _scal[double]
          blas_functions.nrm2 = _nrm2[double]
                                     ^
      ------------------------------------------------------------
      
      sklearn/svm/_liblinear.pyx:58:31: Cannot assign type 'double (int, double *, int) except * nogil' to 'nrm2_func'
      Traceback (most recent call last):
        File "/tmp/pip-build-env-at5n6u8u/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1325, in cythonize_one_helper
          return cythonize_one(*m)
        File "/tmp/pip-build-env-at5n6u8u/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1301, in cythonize_one
          raise CompileError(None, pyx_file)
      Cython.Compiler.Errors.CompileError: sklearn/svm/_liblinear.pyx
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          if error_msg:
              # for SVR: epsilon is called p in libsvm
              error_repl = error_msg.decode('utf-8').replace("p < 0", "epsilon < 0")
              raise ValueError(error_repl)
          cdef BlasFunctions blas_functions
          blas_functions.dot = _dot[double]
                                   ^
      ------------------------------------------------------------
      
      sklearn/svm/_libsvm.pyx:194:29: Cannot assign type 'double (int, double *, int, double *, int) except * nogil' to 'dot_func'
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                             class_weight_label.data, class_weight.data)
          model = set_model(&param, <int> nSV.shape[0], SV.data, SV.shape,
                            support.data, support.shape, sv_coef.strides,
                            sv_coef.data, intercept.data, nSV.data, probA.data, probB.data)
          cdef BlasFunctions blas_functions
          blas_functions.dot = _dot[double]
                                   ^
      ------------------------------------------------------------
      
      sklearn/svm/_libsvm.pyx:358:29: Cannot assign type 'double (int, double *, int, double *, int) except * nogil' to 'dot_func'
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                            sv_coef.data, intercept.data, nSV.data,
                            probA.data, probB.data)
      
          cdef np.npy_intp n_class = get_nr(model)
          cdef BlasFunctions blas_functions
          blas_functions.dot = _dot[double]
                                   ^
      ------------------------------------------------------------
      
      sklearn/svm/_libsvm.pyx:464:29: Cannot assign type 'double (int, double *, int, double *, int) except * nogil' to 'dot_func'
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
              n_class = 1
          else:
              n_class = get_nr(model)
              n_class = n_class * (n_class - 1) // 2
          cdef BlasFunctions blas_functions
          blas_functions.dot = _dot[double]
                                   ^
      ------------------------------------------------------------
      
      sklearn/svm/_libsvm.pyx:570:29: Cannot assign type 'double (int, double *, int, double *, int) except * nogil' to 'dot_func'
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          if error_msg:
              raise ValueError(error_msg)
      
          cdef np.ndarray[np.float64_t, ndim=1, mode='c'] target
          cdef BlasFunctions blas_functions
          blas_functions.dot = _dot[double]
                                   ^
      ------------------------------------------------------------
      
      sklearn/svm/_libsvm.pyx:714:29: Cannot assign type 'double (int, double *, int, double *, int) except * nogil' to 'dot_func'
      Traceback (most recent call last):
        File "/tmp/pip-build-env-at5n6u8u/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1325, in cythonize_one_helper
          return cythonize_one(*m)
        File "/tmp/pip-build-env-at5n6u8u/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1301, in cythonize_one
          raise CompileError(None, pyx_file)
      Cython.Compiler.Errors.CompileError: sklearn/svm/_libsvm.pyx
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          if error_msg:
              free_problem(problem)
              free_param(param)
              raise ValueError(error_msg)
          cdef BlasFunctions blas_functions
          blas_functions.dot = _dot[double]
                                   ^
      ------------------------------------------------------------
      
      sklearn/svm/_libsvm_sparse.pyx:153:29: Cannot assign type 'double (int, double *, int, double *, int) except * nogil' to 'dot_func'
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                                sv_coef.data, intercept.data,
                                nSV.data, probA.data, probB.data)
          #TODO: use check_model
          dec_values = np.empty(T_indptr.shape[0]-1)
          cdef BlasFunctions blas_functions
          blas_functions.dot = _dot[double]
                                   ^
      ------------------------------------------------------------
      
      sklearn/svm/_libsvm_sparse.pyx:284:29: Cannot assign type 'double (int, double *, int, double *, int) except * nogil' to 'dot_func'
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          #TODO: use check_model
          cdef np.npy_intp n_class = get_nr(model)
          cdef int rv
          dec_values = np.empty((T_indptr.shape[0]-1, n_class), dtype=np.float64)
          cdef BlasFunctions blas_functions
          blas_functions.dot = _dot[double]
                                   ^
      ------------------------------------------------------------
      
      sklearn/svm/_libsvm_sparse.pyx:343:29: Cannot assign type 'double (int, double *, int, double *, int) except * nogil' to 'dot_func'
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
              n_class = get_nr(model)
              n_class = n_class * (n_class - 1) // 2
      
          dec_values = np.empty((T_indptr.shape[0] - 1, n_class), dtype=np.float64)
          cdef BlasFunctions blas_functions
          blas_functions.dot = _dot[double]
                                   ^
      ------------------------------------------------------------
      
      sklearn/svm/_libsvm_sparse.pyx:412:29: Cannot assign type 'double (int, double *, int, double *, int) except * nogil' to 'dot_func'
      Traceback (most recent call last):
        File "/tmp/pip-build-env-at5n6u8u/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1325, in cythonize_one_helper
          return cythonize_one(*m)
        File "/tmp/pip-build-env-at5n6u8u/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1301, in cythonize_one
          raise CompileError(None, pyx_file)
      Cython.Compiler.Errors.CompileError: sklearn/svm/_libsvm_sparse.pyx
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          if not is_samples_sorted[0]:
              n_samples = end - start
              memcpy(sorted_samples + start, samples + start,
                     n_samples * sizeof(SIZE_t))
              qsort(sorted_samples + start, n_samples, sizeof(SIZE_t),
                    compare_SIZE_t)
                    ^
      ------------------------------------------------------------
      
      sklearn/tree/_splitter.pyx:1037:14: Cannot assign type 'int (const void *, const void *) except? -1 nogil' to 'int (*)(const void *, const void *) noexcept nogil'
      Traceback (most recent call last):
        File "/tmp/pip-build-env-at5n6u8u/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1325, in cythonize_one_helper
          return cythonize_one(*m)
        File "/tmp/pip-build-env-at5n6u8u/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1301, in cythonize_one
          raise CompileError(None, pyx_file)
      Cython.Compiler.Errors.CompileError: sklearn/tree/_splitter.pyx
Error compiling Cython file:
      ------------------------------------------------------------
      ...
      
              # Initial capacity
              cdef int init_capacity
      
              if tree.max_depth <= 10:
                  init_capacity = (2 ** (tree.max_depth + 1)) - 1
                                                              ^
      ------------------------------------------------------------
      
      sklearn/tree/_tree.pyx:151:56: Cannot assign type 'double' to 'int'
      Traceback (most recent call last):
        File "/tmp/pip-build-env-at5n6u8u/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1325, in cythonize_one_helper
          return cythonize_one(*m)
        File "/tmp/pip-build-env-at5n6u8u/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1301, in cythonize_one
          raise CompileError(None, pyx_file)
      Cython.Compiler.Errors.CompileError: sklearn/tree/_tree.pyx
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
              dec(end)
              # Construct our arguments
              cdef pair[ITYPE_t, DTYPE_t] args
              args.first = key
              args.second = value
              self.my_map.insert(end, args)
                                 ^
      ------------------------------------------------------------
      Cython.Compiler.Errors.CompileError: sklearn/ensemble/_hist_gradient_boosting/splitting.pyx
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.

Environment and installation:

python 3.10

Please give details about your installation:

  • OS: Ubuntu 20.04.6 LTS
  • Is your installation in a virtual environment or conda environment? Yes (Virtual Environment)
  • Python version 3.10
  • Auto-sklearn version (latest)

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 3
  • Comments: 21 (2 by maintainers)

Most upvoted comments

i have a a way to fix it, thank you all and thanks for @AmirAlavi to point it out in other issue.

https://colab.research.google.com/drive/1BXXdGaJX_HxOL-jaL747s_BLYAjPvmCH?usp=sharing

It’s because of the new Cython release a few days ago, and its incompatibility with older scikit-learn. Workaround for now is to

  1. Install older Cython
  2. Make sure that scikit-learn uses that Cython when it’s built

This answer does both of those.