LoginSignup
1

More than 1 year has passed since last update.

TensorFlowのインストール(pip)失敗でハマった話(Could not find a version that satisfies the requirement)

Posted at

1.この記事の内容

長らく使っていなかったDockerfileを使ってDocker Imageをビルドしなおす機会があり,この環境でTensorFlowのpip installが失敗する問題に遭遇しました.
解決まで結構ハマってしまったのですが,初歩的なミスだったので自分への戒めも兼ねて,書き留めることにしました.

結論だけ先に述べておくと,インストール対象のパッケージがサポートしているPythonのバージョンを使いましょう,ということです.

2.エラー内容

「TensorFlow version 2.8.0rc0の要件を満たしていません」といった内容のエラーです.

ERROR: Could not find a version that satisfies the requirement tensorflow==2.8.0rc0 (from versions: none)
ERROR: No matching distribution found for tensorflow==2.8.0rc0

3.原因

Dockerfileのベースイメージに,python:3を設定していたことが原因でした.

FROM python:3
(以下略)

この設定では,Pythonの最新バージョンが引き込まれるわけですが,本記事の執筆時点ではPython 3.11.1となります.
一方,TensorFlow version 2.8.0rc0では対応するPythonバージョンは3.7, 3.8, 3.9, 3.10なので,ここで不整合が起きていました.

4.対策

Dockerfileのベースイメージに設定するPythonバージョンをpython:3.10.9とすることで解決しました.

-FROM python:3
+FROM python:3.10.9

5.さいごに

今回はTensorFlowでこの問題に遭遇しましたが,他のPythonパッケージでも生じうる問題なので,バージョン指定には気を付けないといけないな,と改めて思いました.

6.関連リンク

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1