如何在 python 3.12.1 上安装 PyTorch

ach*_*r99 1 python machine-learning torch

我正在安装 DARTS TimeSeries 库(https://github.com/unit8co/darts/blob/master/INSTALL.md#enabling-optical-dependencies),但遇到了依赖项安装问题。在 DARTS 安装指南中,它说如果我们遇到这个问题,我们必须参考 PyTorch 的官方安装指南,然后尝试再次安装 Darts。然后,当我尝试在 python 3.12.1 上安装 torch 时,我遇到了这个错误:

\n
\n

错误:找不到满足火炬要求的版本(来自版本:无)

\n

错误:找不到火炬的匹配发行版。

\n
\n

怎么解决呢?

\n

我使用 PyCharm 作为 Python 代码编辑器。

\n

我尝试了pip install darts,但它没有安装所有软件包并遇到此错误 error: subprocess-exited-with-error

\n
  pip subprocess to install build dependencies did not run successfully.\n  \xe2\x94\x82 exit code: 1\n  \xe2\x95\xb0\xe2\x94\x80> [136 lines of output]\n      Collecting setuptools>=64.0\n        Obtaining dependency information for setuptools>=64.0 from https://files.pythonhosted.org/packages\n
Run Code Online (Sandbox Code Playgroud)\n

然后,我尝试使用 pip install torch 来安装 torch 并遇到此错误\n错误:找不到满足需求 torch 的版本(来自版本:无)\n错误:找不到 torch 的匹配发行版

\n

use*_*413 5

darts和pytorch目前都支持 Python 版本 3.8 - 3.11,但您使用的是Python 3.12.1 要解决您的问题,请安装受支持的 python 版本并使用虚拟环境来管理需要特定 python 版本的项目。例如,您可以创建一个 Python 3.10 虚拟环境。pip install darts

编辑: 用户 @jkr 指出 pytorch 现在支持 Python 3.11,如官方文档中所示。