无法使用 python 3.11.0 安装 scikit-learn

win*_*ter 5 scikit-learn

I am using below setup\npoetry: 1.2.2\npyenv: 2.3.5-3-g0726e02e\npython: 3.11.0\nscikit-learn: 1.1.2\n\nI am trying to install scikit-learn using command:\n**poetry add scikit-learn **\n\nBut I am getting error as below:\n\n Preparing metadata (pyproject.toml): still running...\n  Preparing metadata (pyproject.toml): finished with status 'error'\n  error: subprocess-exited-with-error\n  \n  \xc3\x97 Preparing metadata (pyproject.toml) did not run successfully.\n  \xe2\x94\x82 exit code: 1\n  \xe2\x95\xb0\xe2\x94\x80> [273 lines of output]\n      Partial import of sklearn during the build process.\n      setup.py:128: DeprecationWarning:\n      \n        `numpy.distutils` is deprecated since NumPy 1.23.0, as a result\n        of the deprecation of `distutils` itself. It will be removed for\n        Python >= 3.12. For older Python versions it will remain present.\n        It is recommended to use `setuptools < 60.0` for those Python versions.\n        For more details, see:\n          https://numpy.org/devdocs/reference/distutils_status_migration.html\n      ....\n      ....\n      ....\n    self.finalize_unix()\n        File "/tmp/pip-build-env-go8f9tm1/overlay/lib/python3.11/site-packages/setuptools/_distutils/command/install.py", line 498, in finalize_unix\n          self.select_scheme("posix_prefix")\n        File "/tmp/pip-build-env-go8f9tm1/overlay/lib/python3.11/site-packages/setuptools/_distutils/command/install.py", line 528, in select_scheme\n          return self._select_scheme(resolved)\n                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n        File "/tmp/pip-build-env-go8f9tm1/overlay/lib/python3.11/site-packages/setuptools/_distutils/command/install.py", line 537, in _select_scheme\n          setattr(self, attrname, scheme[key])\n                                  ~~~~~~^^^^^\n      KeyError: 'headers'\n      [end of output]\n  \n  note: This error originates from a subprocess, and is likely not a problem with pip.\nerror: metadata-generation-failed\n\nwhat I am missing?\n      \n      \n
Run Code Online (Sandbox Code Playgroud)\n

正如错误消息中建议尝试使用 setuptools < 60.0.0\n我尝试了诗歌运行 pip install setuptools==59.8.0

\n

在执行诗歌添加 scikit-learn时,它会自动将setuptools 升级到版本 65.0并因错误而失败。

\n

尽管如此,使用上述设置(不包括 scikit-learn)我能够成功安装 numpy、pandas、scipy 等,而无需降级 setuptools 版本。

\n

小智 5

我是通过以下方式得到的:pip3 install -U scikit-learn

  • 请不要重复答案 (3认同)

小智 1

这应该安装 scikit-learn:

pip install -U sklearn

它在我的 Python 3.11 系统上运行。