AttributeError: cython_sources [duplicate]
Asked Answered
H

1

16

I am using:

python: 3.12

OS: Windows 11 Home

I tried to install catboost==1.2.2

I am getting this error:

C:\Windows\System32>py -3 -m pip install catboost==1.2.2
Collecting catboost==1.2.2
  Downloading catboost-1.2.2.tar.gz (60.1 MB)
     ---------------------------------------- 60.1/60.1 MB 5.1 MB/s eta 0:00:00
  Installing build dependencies ... error
  error: subprocess-exited-with-error

  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [135 lines of output]
      Collecting setuptools>=64.0
        Using cached setuptools-68.2.2-py3-none-any.whl (807 kB)
      Collecting wheel
        Using cached wheel-0.41.3-py3-none-any.whl (65 kB)
      Collecting jupyterlab
        Downloading jupyterlab-4.0.8-py3-none-any.whl (9.2 MB)
           ---------------------------------------- 9.2/9.2 MB 7.8 MB/s eta 0:00:00
      Collecting conan<=1.59,>=1.57
        Downloading conan-1.59.0.tar.gz (780 kB)
           -------------------------------------- 781.0/781.0 kB 4.9 MB/s eta 0:00:00
        Installing build dependencies: started
        Installing build dependencies: finished with status 'done'
        Getting requirements to build wheel: started
        Getting requirements to build wheel: finished with status 'done'
        Preparing metadata (pyproject.toml): started
        Preparing metadata (pyproject.toml): finished with status 'done'
      Collecting async-lru>=1.0.0 (from jupyterlab)
        Downloading async_lru-2.0.4-py3-none-any.whl (6.1 kB)
      Collecting ipykernel (from jupyterlab)
        Downloading ipykernel-6.26.0-py3-none-any.whl (114 kB)
           -------------------------------------- 114.3/114.3 kB 6.5 MB/s eta 0:00:00
      Collecting jinja2>=3.0.3 (from jupyterlab)
        Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB)
           -------------------------------------- 133.1/133.1 kB 7.7 MB/s eta 0:00:00
      Collecting jupyter-core (from jupyterlab)
        Downloading jupyter_core-5.5.0-py3-none-any.whl (28 kB)
      Collecting jupyter-lsp>=2.0.0 (from jupyterlab)
        Downloading jupyter_lsp-2.2.0-py3-none-any.whl (65 kB)
           ---------------------------------------- 66.0/66.0 kB 3.7 MB/s eta 0:00:00
      Collecting jupyter-server<3,>=2.4.0 (from jupyterlab)
        Downloading jupyter_server-2.10.1-py3-none-any.whl (378 kB)
           -------------------------------------- 378.6/378.6 kB 4.7 MB/s eta 0:00:00
      Collecting jupyterlab-server<3,>=2.19.0 (from jupyterlab)
        Downloading jupyterlab_server-2.25.1-py3-none-any.whl (58 kB)
           ---------------------------------------- 59.0/59.0 kB 3.0 MB/s eta 0:00:00
      Collecting notebook-shim>=0.2 (from jupyterlab)
        Downloading notebook_shim-0.2.3-py3-none-any.whl (13 kB)
      Collecting packaging (from jupyterlab)
        Downloading packaging-23.2-py3-none-any.whl (53 kB)
           ---------------------------------------- 53.0/53.0 kB 2.7 MB/s eta 0:00:00
      Collecting tornado>=6.2.0 (from jupyterlab)
        Downloading tornado-6.3.3-cp38-abi3-win_amd64.whl (429 kB)
           -------------------------------------- 429.2/429.2 kB 9.1 MB/s eta 0:00:00
      Collecting traitlets (from jupyterlab)
        Downloading traitlets-5.13.0-py3-none-any.whl (84 kB)
           ---------------------------------------- 85.0/85.0 kB 4.7 MB/s eta 0:00:00
      Collecting requests<3.0.0,>=2.25 (from conan<=1.59,>=1.57)
        Downloading requests-2.31.0-py3-none-any.whl (62 kB)
           ---------------------------------------- 62.6/62.6 kB ? eta 0:00:00
      Collecting urllib3<1.27,>=1.26.6 (from conan<=1.59,>=1.57)
        Downloading urllib3-1.26.18-py2.py3-none-any.whl (143 kB)
           -------------------------------------- 143.8/143.8 kB 4.3 MB/s eta 0:00:00
      Collecting colorama<0.5.0,>=0.3.3 (from conan<=1.59,>=1.57)
        Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB)
      Collecting PyYAML<=6.0,>=3.11 (from conan<=1.59,>=1.57)
        Downloading PyYAML-6.0.tar.gz (124 kB)
           -------------------------------------- 125.0/125.0 kB 3.6 MB/s eta 0:00:00
        Installing build dependencies: started
        Installing build dependencies: finished with status 'done'
        Getting requirements to build wheel: started
        Getting requirements to build wheel: finished with status 'error'
        error: subprocess-exited-with-error

        Getting requirements to build wheel did not run successfully.
        exit code: 1

        [54 lines of output]
        running egg_info
        writing lib\PyYAML.egg-info\PKG-INFO
        writing dependency_links to lib\PyYAML.egg-info\dependency_links.txt
        writing top-level names to lib\PyYAML.egg-info\top_level.txt
        Traceback (most recent call last):
          File "C:\Users\talta\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
            main()
          File "C:\Users\talta\AppData\Local\Programs\Python\Python312\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\talta\AppData\Local\Programs\Python\Python312\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\talta\AppData\Local\Temp\pip-build-env-w9d6umo6\overlay\Lib\site-packages\setuptools\build_meta.py", line 355, in get_requires_for_build_wheel
            return self._get_build_requires(config_settings, requirements=['wheel'])
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "C:\Users\talta\AppData\Local\Temp\pip-build-env-w9d6umo6\overlay\Lib\site-packages\setuptools\build_meta.py", line 325, in _get_build_requires
            self.run_setup()
          File "C:\Users\talta\AppData\Local\Temp\pip-build-env-w9d6umo6\overlay\Lib\site-packages\setuptools\build_meta.py", line 341, in run_setup
            exec(code, locals())
          File "<string>", line 288, in <module>
          File "C:\Users\talta\AppData\Local\Temp\pip-build-env-w9d6umo6\overlay\Lib\site-packages\setuptools\__init__.py", line 103, in setup
            return distutils.core.setup(**attrs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "C:\Users\talta\AppData\Local\Temp\pip-build-env-w9d6umo6\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 185, in setup
            return run_commands(dist)
                   ^^^^^^^^^^^^^^^^^^
          File "C:\Users\talta\AppData\Local\Temp\pip-build-env-w9d6umo6\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 201, in run_commands
            dist.run_commands()
          File "C:\Users\talta\AppData\Local\Temp\pip-build-env-w9d6umo6\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 969, in run_commands
            self.run_command(cmd)
          File "C:\Users\talta\AppData\Local\Temp\pip-build-env-w9d6umo6\overlay\Lib\site-packages\setuptools\dist.py", line 989, in run_command
            super().run_command(command)
          File "C:\Users\talta\AppData\Local\Temp\pip-build-env-w9d6umo6\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
            cmd_obj.run()
          File "C:\Users\talta\AppData\Local\Temp\pip-build-env-w9d6umo6\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 318, in run
            self.find_sources()
          File "C:\Users\talta\AppData\Local\Temp\pip-build-env-w9d6umo6\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 326, in find_sources
            mm.run()
          File "C:\Users\talta\AppData\Local\Temp\pip-build-env-w9d6umo6\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 548, in run
            self.add_defaults()
          File "C:\Users\talta\AppData\Local\Temp\pip-build-env-w9d6umo6\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 586, in add_defaults
            sdist.add_defaults(self)
          File "C:\Users\talta\AppData\Local\Temp\pip-build-env-w9d6umo6\overlay\Lib\site-packages\setuptools\command\sdist.py", line 113, in add_defaults
            super().add_defaults()
          File "C:\Users\talta\AppData\Local\Temp\pip-build-env-w9d6umo6\overlay\Lib\site-packages\setuptools\_distutils\command\sdist.py", line 251, in add_defaults
            self._add_defaults_ext()
          File "C:\Users\talta\AppData\Local\Temp\pip-build-env-w9d6umo6\overlay\Lib\site-packages\setuptools\_distutils\command\sdist.py", line 336, in _add_defaults_ext
            self.filelist.extend(build_ext.get_source_files())
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "<string>", line 204, in get_source_files
          File "C:\Users\talta\AppData\Local\Temp\pip-build-env-w9d6umo6\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 107, in __getattr__
            raise AttributeError(attr)
        AttributeError: cython_sources
        [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.

      [notice] A new release of pip is available: 23.1.2 -> 23.3.1
      [notice] To update, run: C:\Users\talta\AppData\Local\Programs\Python\Python312\python.exe -m pip install --upgrade pip
      [end of output]

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

× pip subprocess to install build dependencies 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.

Any workaround or solutions?

Comments and answers are much appreciated.

Hosea answered 15/11, 2023 at 19:31 Comment(0)
H
47

Edit: Adding the work arounds which worked for people.

Two workarounds exist:

1.Preinstall cython<3, then install pyyaml without build isolation, then install the rest of your dependencies "AttributeError: cython_sources" with Cython 3.0.0a10 #601 (comment)

$ pip install "cython<3.0.0" wheel
$ pip install "pyyaml==5.4.1" --no-build-isolation
$ pip install -r requirements.txt

2.Use a constraints file to force pip to use cython<3 at build time "AttributeError: cython_sources" with Cython 3.0.0a10 #601 (comment)

$ echo "cython<3" > /tmp/constraint.txt
$ PIP_CONSTRAINT=/tmp/constraint.txt pip install -r requirements.txt

Credit to @astrojuanlu

https://github.com/yaml/pyyaml/issues/601#issuecomment-1813963845



Looks like there is an ongoing issue for installation of catboost==1.2.2

git links:

https://github.com/catboost/catboost/issues/2520

https://github.com/catboost/catboost/issues/2469

PyYAML and Cython are the culprit.

Here is the main git : https://github.com/yaml/pyyaml/issues/601

Hosea answered 16/11, 2023 at 1:47 Comment(3)
Cython rather than Cypthon?Ginsberg
Cython is not a culprit in itself, it's the reluctancy of PyYAML to support Cython 3, which was announced years in advance, and which is now very widely adopted.Ginsberg
meanwhile PyYAML has fixed the incompatibility with Cython 3, you just need to use a newer version of it.Ginsberg

© 2022 - 2024 — McMap. All rights reserved.