ERROR: Could not find a version that satisfies the requirement torch (from versions: none) の解決方法

Tue, January 2, 2024 - 2 min read

ERROR: Could not find a version that satisfies the requirement torch (from versions: none)を解決して、PyTorchをインストールした方法をご紹介します。

$ pip install torch
ERROR: Could not find a version that satisfies the requirement torch (from versions: none)
$ python -V
Python 3.12.1

PyTorch公式サイトのINSTALL PYTORCHからインストールの必須要件は満たしてそうなことは確認しました。

NOTE: Latest PyTorch requires Python 3.8 or later. For more details, see Python section below.

と記載されていたので、torch · PyPIを確認したところ、Pythonは3.10までしか未だサポートされていないようでした。

Programming Language * C++ * Python :: 3 * Python :: 3.8 * Python :: 3.9 * Python :: 3.10

https://www.python.org/downloads/を確認して3.10.*の最新バージョン3.10.13をインストールする。

asdf install python 3.10.13
asdf local python 3.10.13
$ pip install torch
...
Installing collected packages: mpmath, typing-extensions, sympy, networkx, MarkupSafe, fsspec, filelock, jinja2, torch
Successfully installed MarkupSafe-2.1.3 filelock-3.13.1 fsspec-2023.12.2 jinja2-3.1.2 mpmath-1.3.0 networkx-3.2.1 sympy-1.12 torch-2.1.2 typing-extensions-4.9.0

以上、PyTorchを無事にインストールした、現場からお送りしました。