pip install tensorflow==1.x ができない
こんなエラーになるとき
python -m pip install tensorflow==1.15
ERROR: Could not find a version that satisfies the requirement tensorflow==1.15 (from versions: 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.2.1, 2.3.0rc0, 2.3.0rc1, 2.3.0rc2, 2.3.0, 2.3.1, 2.4.0rc0, 2.4.0rc1, 2.4.0rc2, 2.4.0rc3, 2.4.0rc4)
ERROR: No matching distribution found for tensorflow==1.15
原因
Pythonのバージョンが合っていないことが原因の可能性が高いです。
例えばPyPIのtensorflow 1.15.4 のページ↓を見ると、tensorflow 1.15.4 が用意しているパッケージはpython 3.5, 3.6, 3.7 用しか提供されていません。
https://pypi.org/project/tensorflow/1.15.4/#files
なので、Python 3.8や3.9でpip installしても対応するパッケージがないので入りません。
解決方法
Pythonのバージョンをpython 3.5, 3.6, 3.7にすればインストールできます。
# バージョン確認
$ python --version
Python 3.7.9
# インストール
$ python -m pip install tensorflow==1.15
///省略
# 確認。モジュールはあることが確認できる
$ python -m tensorflow
/.../bin/python: No module named tensorflow.__main__; 'tensorflow' is a package and cannot be directly executed
参考