Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On Windows, unable to install Surprise with poetry due to Cythonizing error #484

Open
omar-sobhy opened this issue Nov 24, 2024 · 3 comments

Comments

@omar-sobhy
Copy link

Description

Trying to install the package with poetry on Windows (maybe Linux too? haven't tested it myself) gives an error.

Skimming through the error log, this seems to be an error because of the usage of np.int_t, which is no longer supported by numpy.

Steps/Code to Reproduce

Run poetry add scikit-surprise.

Expected Results

The package installs successfully.

Actual Results

Output from `poetry add scikit-surprise` command (long output)
> poetry add scikit-surprise                                       
Using version ^1.1.4 for scikit-surprise

Updating dependencies
Resolving dependencies... (0.6s)

Package operations: 1 install, 0 updates, 0 removals

  - Installing scikit-surprise (1.1.4): Failed

  ChefBuildError

  Backend subprocess exited when trying to invoke get_requires_for_build_wheel
  
  
  Error compiling Cython file:
  ------------------------------------------------------------
  ...
          self.avg_cltr_i = avg_cltr_i
          self.avg_cocltr = avg_cocltr
  
          return self
  
      def compute_averages(self, np.ndarray[np.int_t] cltr_u,
                                               ^
  ------------------------------------------------------------
  
  surprise\prediction_algorithms\co_clustering.pyx:157:45: Invalid type.
  Compiling surprise/similarities.pyx because it changed.
  Compiling surprise/prediction_algorithms/matrix_factorization.pyx because it changed.
  Compiling surprise/prediction_algorithms/optimize_baselines.pyx because it changed.
  Compiling surprise/prediction_algorithms/slope_one.pyx because it changed.
  Compiling surprise/prediction_algorithms/co_clustering.pyx because it changed.
  [1/5] Cythonizing surprise/prediction_algorithms/co_clustering.pyx
  Traceback (most recent call last):
    File "C:\Users\Omar\pipx\venvs\poetry\Lib\site-packages\pyproject_hooks\_in_process\_in_process.py", line 389, in <module>
      main()
      ~~~~^^
    File "C:\Users\Omar\pipx\venvs\poetry\Lib\site-packages\pyproject_hooks\_in_process\_in_process.py", line 373, in main
      json_out["return_val"] = hook(**hook_input["kwargs"])
                               ~~~~^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Omar\pipx\venvs\poetry\Lib\site-packages\pyproject_hooks\_in_process\_in_process.py", line 143, in get_requires_for_build_wheel
      return hook(config_settings)
    File "C:\Users\Omar\AppData\Local\Temp\tmpnm79ijzm\.venv\Lib\site-packages\setuptools\build_meta.py", line 334, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=[])
             ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Omar\AppData\Local\Temp\tmpnm79ijzm\.venv\Lib\site-packages\setuptools\build_meta.py", line 304, in _get_build_requires
      self.run_setup()
      ~~~~~~~~~~~~~~^^
    File "C:\Users\Omar\AppData\Local\Temp\tmpnm79ijzm\.venv\Lib\site-packages\setuptools\build_meta.py", line 320, in run_setup
      exec(code, locals())
      ~~~~^^^^^^^^^^^^^^^^
    File "<string>", line 116, in <module>
    File "C:\Users\Omar\AppData\Local\Temp\tmpnm79ijzm\.venv\Lib\site-packages\Cython\Build\Dependencies.py", line 1154, in cythonize
      cythonize_one(*args)
      ~~~~~~~~~~~~~^^^^^^^
    File "C:\Users\Omar\AppData\Local\Temp\tmpnm79ijzm\.venv\Lib\site-packages\Cython\Build\Dependencies.py", line 1321, in cythonize_one
      raise CompileError(None, pyx_file)
  Cython.Compiler.Errors.CompileError: surprise/prediction_algorithms/co_clustering.pyx
  

  at ~\pipx\venvs\poetry\Lib\site-packages\poetry\installation\chef.py:164 in _prepare
      160│
      161│                 error = ChefBuildError("\n\n".join(message_parts))
      162│
      163│             if error is not None:
    → 164│                 raise error from None
      165│
      166│             return path
      167│
      168│     def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:

Note: This error originates from the build backend, and is likely not a problem with poetry but with scikit-surprise (1.1.4) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "scikit-surprise (==1.1.4)"'.

Versions

Windows-11-10.0.22631-SP0
Python 3.13.0 (tags/v3.13.0:60403a5, Oct 7 2024, 09:38:07) [MSC v.1941 64 bit (AMD64)]

@shaibi007
Copy link

I have similar cython issue when installing using pip.

@NicolasHug
Copy link
Owner

Hi folks, you're probably using numpy 2 ? I haven't had a chance to add numpy 2 compatibility yet. Happy to get some help on this, in the meantime I think you'll have to use numpy < 2

@shaibi007
Copy link

I have tried downgrading numpy and reinstall surprise.
I get some errors with the installation:

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [45 lines of output]

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
          self.avg_cltr_i = avg_cltr_i
          self.avg_cocltr = avg_cocltr

          return self

      def compute_averages(self, np.ndarray[np.int_t] cltr_u,
                                               ^
  ------------------------------------------------------------

  surprise\prediction_algorithms\co_clustering.pyx:157:45: Invalid type.
  Compiling surprise/similarities.pyx because it changed.
  Compiling surprise/prediction_algorithms/matrix_factorization.pyx because it changed.
  Compiling surprise/prediction_algorithms/optimize_baselines.pyx because it changed.
  Compiling surprise/prediction_algorithms/slope_one.pyx because it changed.
  Compiling surprise/prediction_algorithms/co_clustering.pyx because it changed.
  [1/5] Cythonizing surprise/prediction_algorithms/co_clustering.pyx
  Traceback (most recent call last):
    File "C:\Users\rshoaib\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
      main()
      ~~~~^^
    File "C:\Users\rshoaib\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
                               ~~~~^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\rshoaib\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
      return hook(config_settings)
    File "C:\Users\rshoaib\AppData\Local\Temp\pip-build-env-bihqyyo5\overlay\Lib\site-packages\setuptools\build_meta.py", line 334, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=[])
             ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\rshoaib\AppData\Local\Temp\pip-build-env-bihqyyo5\overlay\Lib\site-packages\setuptools\build_meta.py", line 304, in _get_build_requires
      self.run_setup()
      ~~~~~~~~~~~~~~^^
    File "C:\Users\rshoaib\AppData\Local\Temp\pip-build-env-bihqyyo5\overlay\Lib\site-packages\setuptools\build_meta.py", line 320, in run_setup
      exec(code, locals())
      ~~~~^^^^^^^^^^^^^^^^
    File "<string>", line 116, in <module>
    File "C:\Users\rshoaib\AppData\Local\Temp\pip-build-env-bihqyyo5\overlay\Lib\site-packages\Cython\Build\Dependencies.py", line 1154, in cythonize
      cythonize_one(*args)
      ~~~~~~~~~~~~~^^^^^^^
    File "C:\Users\rshoaib\AppData\Local\Temp\pip-build-env-bihqyyo5\overlay\Lib\site-packages\Cython\Build\Dependencies.py", line 1321, in cythonize_one
      raise CompileError(None, pyx_file)
  Cython.Compiler.Errors.CompileError: surprise/prediction_algorithms/co_clustering.pyx
  [end of output]

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

× Getting requirements to build wheel 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants