属性错误:cython_sources

Pal*_*ine 7 python python-3.x catboost python-3.12

我在用:

\n
python: 3.12\n\nOS: Windows 11 Home\n
Run Code Online (Sandbox Code Playgroud)\n

我尝试安装catboost==1.2.2

\n

我收到此错误:

\n
C:\\Windows\\System32>py -3 -m pip install catboost==1.2.2\nCollecting catboost==1.2.2\n  Downloading catboost-1.2.2.tar.gz (60.1 MB)\n     ---------------------------------------- 60.1/60.1 MB 5.1 MB/s eta 0:00:00\n  Installing build dependencies ... error\n  error: subprocess-exited-with-error\n\n  \xc3\x97 pip subprocess to install build dependencies did not run successfully.\n  \xe2\x94\x82 exit code: 1\n  \xe2\x95\xb0\xe2\x94\x80> [135 lines of output]\n      Collecting setuptools>=64.0\n        Using cached setuptools-68.2.2-py3-none-any.whl (807 kB)\n      Collecting wheel\n        Using cached wheel-0.41.3-py3-none-any.whl (65 kB)\n      Collecting jupyterlab\n        Downloading jupyterlab-4.0.8-py3-none-any.whl (9.2 MB)\n           ---------------------------------------- 9.2/9.2 MB 7.8 MB/s eta 0:00:00\n      Collecting conan<=1.59,>=1.57\n        Downloading conan-1.59.0.tar.gz (780 kB)\n           -------------------------------------- 781.0/781.0 kB 4.9 MB/s eta 0:00:00\n        Installing build dependencies: started\n        Installing build dependencies: finished with status 'done'\n        Getting requirements to build wheel: started\n        Getting requirements to build wheel: finished with status 'done'\n        Preparing metadata (pyproject.toml): started\n        Preparing metadata (pyproject.toml): finished with status 'done'\n      Collecting async-lru>=1.0.0 (from jupyterlab)\n        Downloading async_lru-2.0.4-py3-none-any.whl (6.1 kB)\n      Collecting ipykernel (from jupyterlab)\n        Downloading ipykernel-6.26.0-py3-none-any.whl (114 kB)\n           -------------------------------------- 114.3/114.3 kB 6.5 MB/s eta 0:00:00\n      Collecting jinja2>=3.0.3 (from jupyterlab)\n        Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB)\n           -------------------------------------- 133.1/133.1 kB 7.7 MB/s eta 0:00:00\n      Collecting jupyter-core (from jupyterlab)\n        Downloading jupyter_core-5.5.0-py3-none-any.whl (28 kB)\n      Collecting jupyter-lsp>=2.0.0 (from jupyterlab)\n        Downloading jupyter_lsp-2.2.0-py3-none-any.whl (65 kB)\n           ---------------------------------------- 66.0/66.0 kB 3.7 MB/s eta 0:00:00\n      Collecting jupyter-server<3,>=2.4.0 (from jupyterlab)\n        Downloading jupyter_server-2.10.1-py3-none-any.whl (378 kB)\n           -------------------------------------- 378.6/378.6 kB 4.7 MB/s eta 0:00:00\n      Collecting jupyterlab-server<3,>=2.19.0 (from jupyterlab)\n        Downloading jupyterlab_server-2.25.1-py3-none-any.whl (58 kB)\n           ---------------------------------------- 59.0/59.0 kB 3.0 MB/s eta 0:00:00\n      Collecting notebook-shim>=0.2 (from jupyterlab)\n        Downloading notebook_shim-0.2.3-py3-none-any.whl (13 kB)\n      Collecting packaging (from jupyterlab)\n        Downloading packaging-23.2-py3-none-any.whl (53 kB)\n           ---------------------------------------- 53.0/53.0 kB 2.7 MB/s eta 0:00:00\n      Collecting tornado>=6.2.0 (from jupyterlab)\n        Downloading tornado-6.3.3-cp38-abi3-win_amd64.whl (429 kB)\n           -------------------------------------- 429.2/429.2 kB 9.1 MB/s eta 0:00:00\n      Collecting traitlets (from jupyterlab)\n        Downloading traitlets-5.13.0-py3-none-any.whl (84 kB)\n           ---------------------------------------- 85.0/85.0 kB 4.7 MB/s eta 0:00:00\n      Collecting requests<3.0.0,>=2.25 (from conan<=1.59,>=1.57)\n        Downloading requests-2.31.0-py3-none-any.whl (62 kB)\n           ---------------------------------------- 62.6/62.6 kB ? eta 0:00:00\n      Collecting urllib3<1.27,>=1.26.6 (from conan<=1.59,>=1.57)\n        Downloading urllib3-1.26.18-py2.py3-none-any.whl (143 kB)\n           -------------------------------------- 143.8/143.8 kB 4.3 MB/s eta 0:00:00\n      Collecting colorama<0.5.0,>=0.3.3 (from conan<=1.59,>=1.57)\n        Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB)\n      Collecting PyYAML<=6.0,>=3.11 (from conan<=1.59,>=1.57)\n        Downloading PyYAML-6.0.tar.gz (124 kB)\n           -------------------------------------- 125.0/125.0 kB 3.6 MB/s eta 0:00:00\n        Installing build dependencies: started\n        Installing build dependencies: finished with status 'done'\n        Getting requirements to build wheel: started\n        Getting requirements to build wheel: finished with status 'error'\n        error: subprocess-exited-with-error\n\n        Getting requirements to build wheel did not run successfully.\n        exit code: 1\n\n        [54 lines of output]\n        running egg_info\n        writing lib\\PyYAML.egg-info\\PKG-INFO\n        writing dependency_links to lib\\PyYAML.egg-info\\dependency_links.txt\n        writing top-level names to lib\\PyYAML.egg-info\\top_level.txt\n        Traceback (most recent call last):\n          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>\n            main()\n          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\n            json_out['return_val'] = hook(**hook_input['kwargs'])\n                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n          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\n            return hook(config_settings)\n                   ^^^^^^^^^^^^^^^^^^^^^\n          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\n            return self._get_build_requires(config_settings, requirements=['wheel'])\n                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n          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\n            self.run_setup()\n          File "C:\\Users\\talta\\AppData\\Local\\Temp\\pip-build-env-w9d6umo6\\overlay\\Lib\\site-packages\\setuptools\\build_meta.py", line 341, in run_setup\n            exec(code, locals())\n          File "<string>", line 288, in <module>\n          File "C:\\Users\\talta\\AppData\\Local\\Temp\\pip-build-env-w9d6umo6\\overlay\\Lib\\site-packages\\setuptools\\__init__.py", line 103, in setup\n            return distutils.core.setup(**attrs)\n                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n          File "C:\\Users\\talta\\AppData\\Local\\Temp\\pip-build-env-w9d6umo6\\overlay\\Lib\\site-packages\\setuptools\\_distutils\\core.py", line 185, in setup\n            return run_commands(dist)\n                   ^^^^^^^^^^^^^^^^^^\n          File "C:\\Users\\talta\\AppData\\Local\\Temp\\pip-build-env-w9d6umo6\\overlay\\Lib\\site-packages\\setuptools\\_distutils\\core.py", line 201, in run_commands\n            dist.run_commands()\n          File "C:\\Users\\talta\\AppData\\Local\\Temp\\pip-build-env-w9d6umo6\\overlay\\Lib\\site-packages\\setuptools\\_distutils\\dist.py", line 969, in run_commands\n            self.run_command(cmd)\n          File "C:\\Users\\talta\\AppData\\Local\\Temp\\pip-build-env-w9d6umo6\\overlay\\Lib\\site-packages\\setuptools\\dist.py", line 989, in run_command\n            super().run_command(command)\n          File "C:\\Users\\talta\\AppData\\Local\\Temp\\pip-build-env-w9d6umo6\\overlay\\Lib\\site-packages\\setuptools\\_distutils\\dist.py", line 988, in run_command\n            cmd_obj.run()\n          File "C:\\Users\\talta\\AppData\\Local\\Temp\\pip-build-env-w9d6umo6\\overlay\\Lib\\site-packages\\setuptools\\command\\egg_info.py", line 318, in run\n            self.find_sources()\n          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\n            mm.run()\n          File "C:\\Users\\talta\\AppData\\Local\\Temp\\pip-build-env-w9d6umo6\\overlay\\Lib\\site-packages\\setuptools\\command\\egg_info.py", line 548, in run\n            self.add_defaults()\n          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\n            sdist.add_defaults(self)\n          File "C:\\Users\\talta\\AppData\\Local\\Temp\\pip-build-env-w9d6umo6\\overlay\\Lib\\site-packages\\setuptools\\command\\sdist.py", line 113, in add_defaults\n            super().add_defaults()\n          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\n            self._add_defaults_ext()\n          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\n            self.filelist.extend(build_ext.get_source_files())\n                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n          File "<string>", line 204, in get_source_files\n          File "C:\\Users\\talta\\AppData\\Local\\Temp\\pip-build-env-w9d6umo6\\overlay\\Lib\\site-packages\\setuptools\\_distutils\\cmd.py", line 107, in __getattr__\n            raise AttributeError(attr)\n        AttributeError: cython_sources\n        [end of output]\n\n        note: This error originates from a subprocess, and is likely not a problem with pip.\n      error: subprocess-exited-with-error\n\n      Getting requirements to build wheel did not run successfully.\n      exit code: 1\n\n      See above for output.\n\n      note: This error originates from a subprocess, and is likely not a problem with pip.\n\n      [notice] A new release of pip is available: 23.1.2 -> 23.3.1\n      [notice] To update, run: C:\\Users\\talta\\AppData\\Local\\Programs\\Python\\Python312\\python.exe -m pip install --upgrade pip\n      [end of output]\n\n  note: This error originates from a subprocess, and is likely not a problem with pip.\nerror: subprocess-exited-with-error\n\n\xc3\x97 pip subprocess to install build dependencies did not run successfully.\n\xe2\x94\x82 exit code: 1\n\xe2\x95\xb0\xe2\x94\x80> See above for output.\n\nnote: This error originates from a subprocess, and is likely not a problem with pip.\n
Run Code Online (Sandbox Code Playgroud)\n

有什么解决方法或解决方案吗?

\n

非常感谢评论和回答。

\n

Pal*_*ine 19

编辑:添加对人们有用的解决方法。

存在两种解决方法

1.Preinstall cython<3,然后在没有构建隔离的情况下安装pyyaml,然后使用 Cython 3.0.0a10 #601 安装其余依赖项“AttributeError: cython_sources”(评论)

$ pip install "cython<3.0.0" wheel
$ pip install "pyyaml==5.4.1" --no-build-isolation
$ pip install -r requirements.txt
Run Code Online (Sandbox Code Playgroud)

2.使用约束文件强制 pip 在构建时使用 cython<3 "AttributeError: cython_sources" with Cython 3.0.0a10 #601 (评论)

$ echo "cython<3" > /tmp/constraint.txt
$ PIP_CONSTRAINT=/tmp/constraint.txt pip install -r requirements.txt
Run Code Online (Sandbox Code Playgroud)

感谢@astrojuanlu

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



看起来安装时存在一个持续的问题catboost==1.2.2

git 链接:

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

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

PyYAML并且Cython是罪魁祸首。

这是主要的 git:https://github.com/yaml/pyyaml/issues/601