CAnBioNet / TkNA

9 stars 1 forks source link

Cython error? #78

Closed cmkobel closed 1 month ago

cmkobel commented 7 months ago

I get this error when following the setup.txt instructions, using conda.

Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [151 lines of output]
      <string>:19: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
      <string>:218: 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:
      ------------------------------------------------------------
      ...
          # smooth
          for i in range(n):
              prev = (n+i-1) % n

              # s[t-m] = xhat[prev, 2+m-1]
              yhat[i] = (xhat[prev, 0] * xhat[prev, 1]**phi) + xhat[prev, 2+m-1]
                                                             ^
      ------------------------------------------------------------

      statsmodels/tsa/exponential_smoothing/_ets_smooth.pyx:156:55: Cannot assign type 'npy_float64 complex' to 'float64_t'

      Error compiling Cython file:
      ------------------------------------------------------------
      ...

              # s[t-m] = xhat[prev, 2+m-1]
              yhat[i] = (xhat[prev, 0] * xhat[prev, 1]**phi) + xhat[prev, 2+m-1]
              # l_t = a * (y_t - s_t-m) + (1-a) * (l_t-1 * b_t-1**phi)
              xhat[i, 0] = (alpha * (y[i] - xhat[prev, 2+m-1])
                            + (1 - alpha) * (xhat[prev, 0] * xhat[prev, 1]**phi))
                            ^
      ------------------------------------------------------------

      statsmodels/tsa/exponential_smoothing/_ets_smooth.pyx:159:22: Cannot assign type 'npy_float64 complex' to 'float64_t'

      Error compiling Cython file:
      ------------------------------------------------------------
      ...
              # l_t = a * (y_t - s_t-m) + (1-a) * (l_t-1 * b_t-1**phi)
              xhat[i, 0] = (alpha * (y[i] - xhat[prev, 2+m-1])
                            + (1 - alpha) * (xhat[prev, 0] * xhat[prev, 1]**phi))
              # b_t = (b*) * (l_t / l_t-1) + (1 - (b*)) * b_t-1**phi
              xhat[i, 1] = (beta_star * (xhat[i, 0] / xhat[prev, 0])
                            + (1 - beta_star) * xhat[prev, 1]**phi)
                            ^
      ------------------------------------------------------------

      statsmodels/tsa/exponential_smoothing/_ets_smooth.pyx:162:22: Cannot assign type 'npy_float64 complex' to 'float64_t'

      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          # smooth
          for i in range(n):
              prev = (n+i-1) % n

              # s[t-m] = xhat[prev, 2+m-1]
              yhat[i] = (xhat[prev, 0] * xhat[prev, 1]**phi) * xhat[prev, 2+m-1]
                                                             ^
      ------------------------------------------------------------

      statsmodels/tsa/exponential_smoothing/_ets_smooth.pyx:191:55: Cannot assign type 'npy_float64 complex' to 'float64_t'

      Error compiling Cython file:
      ------------------------------------------------------------
      ...

              # s[t-m] = xhat[prev, 2+m-1]
              yhat[i] = (xhat[prev, 0] * xhat[prev, 1]**phi) * xhat[prev, 2+m-1]
              # l_t = a * (y_t / s_t-m) + (1-a) * (l_t-1 * b_t-1**phi)
              xhat[i, 0] = (alpha * (y[i] / xhat[prev, 2+m-1])
                            + (1 - alpha) * (xhat[prev, 0] * xhat[prev, 1]**phi))
                            ^
      ------------------------------------------------------------

      statsmodels/tsa/exponential_smoothing/_ets_smooth.pyx:194:22: Cannot assign type 'npy_float64 complex' to 'float64_t'

      Error compiling Cython file:
      ------------------------------------------------------------
      ...
              # l_t = a * (y_t / s_t-m) + (1-a) * (l_t-1 * b_t-1**phi)
              xhat[i, 0] = (alpha * (y[i] / xhat[prev, 2+m-1])
                            + (1 - alpha) * (xhat[prev, 0] * xhat[prev, 1]**phi))
              # b_t = (b*) * (l_t / l_t-1) + (1 - (b*)) * b_t-1**phi
              xhat[i, 1] = (beta_star * (xhat[i, 0] / xhat[prev, 0])
                            + (1 - beta_star) * xhat[prev, 1]**phi)
                            ^
      ------------------------------------------------------------

      statsmodels/tsa/exponential_smoothing/_ets_smooth.pyx:197:22: Cannot assign type 'npy_float64 complex' to 'float64_t'
      Compiling statsmodels/tsa/_stl.pyx because it changed.
      Compiling statsmodels/tsa/holtwinters/_exponential_smoothers.pyx because it changed.
      Compiling statsmodels/tsa/exponential_smoothing/_ets_smooth.pyx because it changed.
      Compiling statsmodels/tsa/_innovations.pyx because it changed.
      Compiling statsmodels/tsa/regime_switching/_hamilton_filter.pyx because it changed.
      Compiling statsmodels/tsa/regime_switching/_kim_smoother.pyx because it changed.
      Compiling statsmodels/tsa/innovations/_arma_innovations.pyx because it changed.
      Compiling statsmodels/nonparametric/linbin.pyx because it changed.
      Compiling statsmodels/robust/_qn.pyx because it changed.
      Compiling statsmodels/nonparametric/_smoothers_lowess.pyx because it changed.
      Compiling statsmodels/tsa/statespace/_initialization.pyx because it changed.
      Compiling statsmodels/tsa/statespace/_representation.pyx because it changed.
      Compiling statsmodels/tsa/statespace/_kalman_filter.pyx because it changed.
      Compiling statsmodels/tsa/statespace/_filters/_conventional.pyx because it changed.
      Compiling statsmodels/tsa/statespace/_filters/_inversions.pyx because it changed.
      Compiling statsmodels/tsa/statespace/_filters/_univariate.pyx because it changed.
      Compiling statsmodels/tsa/statespace/_filters/_univariate_diffuse.pyx because it changed.
      Compiling statsmodels/tsa/statespace/_kalman_smoother.pyx because it changed.
      Compiling statsmodels/tsa/statespace/_smoothers/_alternative.pyx because it changed.
      Compiling statsmodels/tsa/statespace/_smoothers/_classical.pyx because it changed.
      Compiling statsmodels/tsa/statespace/_smoothers/_conventional.pyx because it changed.
      Compiling statsmodels/tsa/statespace/_smoothers/_univariate.pyx because it changed.
      Compiling statsmodels/tsa/statespace/_smoothers/_univariate_diffuse.pyx because it changed.
      Compiling statsmodels/tsa/statespace/_simulation_smoother.pyx because it changed.
      Compiling statsmodels/tsa/statespace/_cfa_simulation_smoother.pyx because it changed.
      Compiling statsmodels/tsa/statespace/_tools.pyx because it changed.
      [ 1/26] Cythonizing statsmodels/nonparametric/_smoothers_lowess.pyx
      [ 2/26] Cythonizing statsmodels/nonparametric/linbin.pyx
      [ 3/26] Cythonizing statsmodels/robust/_qn.pyx
      [ 4/26] Cythonizing statsmodels/tsa/_innovations.pyx
      [ 5/26] Cythonizing statsmodels/tsa/_stl.pyx
      [ 6/26] Cythonizing statsmodels/tsa/exponential_smoothing/_ets_smooth.pyx
      Traceback (most recent call last):
        File "/glittertind/home/carl/miniconda3/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/glittertind/home/carl/miniconda3/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/glittertind/home/carl/miniconda3/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/glittertind/tmp/pip-build-env-i2m9oxax/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/glittertind/tmp/pip-build-env-i2m9oxax/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "/glittertind/tmp/pip-build-env-i2m9oxax/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 480, in run_setup
          super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
        File "/glittertind/tmp/pip-build-env-i2m9oxax/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 344, in <module>
        File "/glittertind/tmp/pip-build-env-i2m9oxax/overlay/lib/python3.11/site-packages/Cython/Build/Dependencies.py", line 1154, in cythonize
          cythonize_one(*args)
        File "/glittertind/tmp/pip-build-env-i2m9oxax/overlay/lib/python3.11/site-packages/Cython/Build/Dependencies.py", line 1321, in cythonize_one
          raise CompileError(None, pyx_file)
      Cython.Compiler.Errors.CompileError: statsmodels/tsa/exponential_smoothing/_ets_smooth.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.
(oslo) carl@threadripper TkNA $ 

My system is Linux Debian: Linux threadripper 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.38-1 (2023-07-14) x86_64 GNU/Linux

conda 23.7.4

I'm not so acquainted with pip and cython. Does anyone have a lead on how to solve this?

oveoyas commented 7 months ago

I also got this error when installing requirements.txt, but installing a newer version of statsmodels (0.13.5) worked for me. In other words, just change the line in requirements.txt to statsmodels==0.13.5.

newmanno commented 1 month ago

Thanks for the fix :)