ターミナルで
eras shobu$ pip install tensorflow --ignore-installed --user
と打ってインストールしようとしたら
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
twisted 18.7.0 requires PyHamcrest>=1.9.0, which is not installed.
というエラーが出てしまいました。
バージョンが問題だと言っているのですが、調べてもパッケージがどうのこうのというのが多くてわかりません。
どなたか教えてください。お願い致します。
> pip's dependency resolver...
インストール済みのモジュールの依存関係がおかしいようです
参考
https://qiita.com/ksato9700/items/ec30d726a1508c7985a0
> twisted 18.7.0 requires PyHamcrest>=1.9.0, which is not installed.
PyHamcrestのバージョンが1.9.0以上のを入れる必要があるようです
PyHamcrestのバージョンは
Successfully installed PyHamcrest-2.0.2
アップデートしました。
そして
--use-feature=2020-resolver
をつけて実行したところ
WARNING: --use-feature=2020-resolver no longer has any effect, since it is now the default dependency resolver in pip. This will become an error in pip 21.0.
と
WARNING: Running pip as root will break packages and permissions. You should install packages reliably by using venv: https://pip.pypa.io/warnings/venv
が出てしまいインストールできません。
どうしたらいいですか?
> WARNING: --use-feature=2020-resolver no longer has any effect
は、無視してください
現在はそれ付けなくてもデフォルト有効なので要らないよ、って言ってるだけです
申し訳ございません
気持ちが急いてちゃんと読めていませんでした。
また、つけなくても
WARNING: Running pip as root will break packages and permissions. You should install packages reliably by using venv: https://pip.pypa.io/warnings/venv
が出るのですが、そうすればよろしいのでしょうか?
> WARNING: Running pip as root...
pip install...
を実行した後、その「WARNING」以外に、何か表示されてませんか?
表示されてることがあれば、それも書いてください
「WARNING」はエラーではないので、表示されてるからといってインストール失敗してるとは限らないので
これが全部です。
ourin:keras shobu$ sudo pip install tensorflow
Password:
WARNING: The directory '/Users/****/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
Requirement already satisfied: tensorflow in /Users/****/.local/lib/python3.7/site-packages (2.5.0)
Requirement already satisfied: h5py~=3.1.0 in /Users/****/.local/lib/python3.7/site-packages (from tensorflow) (3.1.0)
Requirement already satisfied: astunparse~=1.6.3 in /Users/****/.local/lib/python3.7/site-packages (from tensorflow) (1.6.3)
Requirement already satisfied: flatbuffers~=1.12.0 in /Users/****/.local/lib/python3.7/site-packages (from tensorflow) (1.12)
Requirement already satisfied: keras-nightly~=2.5.0.dev in /Users/****/.local/lib/python3.7/site-packages (from tensorflow) (2.5.0.dev2021032900)
Requirement already satisfied: wheel~=0.35 in /Users/****/.local/lib/python3.7/site-packages (from tensorflow) (0.36.2)
Requirement already satisfied: tensorflow-estimator<2.6.0,>=2.5.0rc0 in /Users/****/.local/lib/python3.7/site-packages (from tensorflow) (2.5.0)
Requirement already satisfied: termcolor~=1.1.0 in /Users/****/.local/lib/python3.7/site-packages (from tensorflow) (1.1.0)
Requirement already satisfied: typing-extensions~=3.7.4 in /Users/****/.local/lib/python3.7/site-packages (from tensorflow) (3.7.4.3)
Requirement already satisfied: tensorboard~=2.5 in /Users/****/.local/lib/python3.7/site-packages (from tensorflow) (2.5.0)
Requirement already satisfied: absl-py~=0.10 in /Users/****/.local/lib/python3.7/site-packages (from tensorflow) (0.12.0)
Requirement already satisfied: keras-preprocessing~=1.1.2 in /Users/****/.local/lib/python3.7/site-packages (from tensorflow) (1.1.2)
Requirement already satisfied: six~=1.15.0 in /Users/****/.local/lib/python3.7/site-packages (from tensorflow) (1.15.0)
Requirement already satisfied: wrapt~=1.12.1 in /Users/****/.local/lib/python3.7/site-packages (from tensorflow) (1.12.1)
Requirement already satisfied: grpcio~=1.34.0 in /Users/****/.local/lib/python3.7/site-packages (from tensorflow) (1.34.1)
Requirement already satisfied: google-pasta~=0.2 in /Users/****/.local/lib/python3.7/site-packages (from tensorflow) (0.2.0)
Requirement already satisfied: opt-einsum~=3.3.0 in /Users/****/.local/lib/python3.7/site-packages (from tensorflow) (3.3.0)
Requirement already satisfied: gast==0.4.0 in /Users/****/.local/lib/python3.7/site-packages (from tensorflow) (0.4.0)
Requirement already satisfied: numpy~=1.19.2 in /Users/****/.local/lib/python3.7/site-packages (from tensorflow) (1.19.5)
Requirement already satisfied: protobuf>=3.9.2 in /Users/****/.local/lib/python3.7/site-packages (from tensorflow) (3.17.1)
Requirement already satisfied: cached-property in /Users/****/.local/lib/python3.7/site-packages (from h5py~=3.1.0->tensorflow) (1.5.2)
Requirement already satisfied: werkzeug>=0.11.15 in /Users/****/.local/lib/python3.7/site-packages (from tensorboard~=2.5->tensorflow) (2.0.1)
Requirement already satisfied: google-auth<2,>=1.6.3 in /Users/****/.local/lib/python3.7/site-packages (from tensorboard~=2.5->tensorflow) (1.30.1)
Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in /Users/****/.local/lib/python3.7/site-packages (from tensorboard~=2.5->tensorflow) (1.8.0)
Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in /Users/****/.local/lib/python3.7/site-packages (from tensorboard~=2.5->tensorflow) (0.4.4)
Requirement already satisfied: markdown>=2.6.8 in /Users/****/.local/lib/python3.7/site-packages (from tensorboard~=2.5->tensorflow) (3.3.4)
Requirement already satisfied: setuptools>=41.0.0 in /Users/****/.local/lib/python3.7/site-packages (from tensorboard~=2.5->tensorflow) (57.0.0)
Requirement already satisfied: tensorboard-data-server<0.7.0,>=0.6.0 in /Users/****/.local/lib/python3.7/site-packages (from tensorboard~=2.5->tensorflow) (0.6.1)
Requirement already satisfied: requests<3,>=2.21.0 in /Users/****/.local/lib/python3.7/site-packages (from tensorboard~=2.5->tensorflow) (2.25.1)
Requirement already satisfied: rsa<5,>=3.1.4 in /Users/****/.local/lib/python3.7/site-packages (from google-auth<2,>=1.6.3->tensorboard~=2.5->tensorflow) (4.7.2)
Requirement already satisfied: cachetools<5.0,>=2.0.0 in /Users/****/.local/lib/python3.7/site-packages (from google-auth<2,>=1.6.3->tensorboard~=2.5->tensorflow) (4.2.2)
Requirement already satisfied: pyasn1-modules>=0.2.1 in /Users/****/.local/lib/python3.7/site-packages (from google-auth<2,>=1.6.3->tensorboard~=2.5->tensorflow) (0.2.8)
Requirement already satisfied: requests-oauthlib>=0.7.0 in /Users/****/.local/lib/python3.7/site-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard~=2.5->tensorflow) (1.3.0)
Requirement already satisfied: importlib-metadata in /Users/****/.local/lib/python3.7/site-packages (from markdown>=2.6.8->tensorboard~=2.5->tensorflow) (4.3.1)
Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in /Users/****/.local/lib/python3.7/site-packages (from pyasn1-modules>=0.2.1->google-auth<2,>=1.6.3->tensorboard~=2.5->tensorflow) (0.4.8)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Users/****/.local/lib/python3.7/site-packages (from requests<3,>=2.21.0->tensorboard~=2.5->tensorflow) (1.26.5)
Requirement already satisfied: certifi>=2017.4.17 in /Users/****/.local/lib/python3.7/site-packages (from requests<3,>=2.21.0->tensorboard~=2.5->tensorflow) (2021.5.30)
Requirement already satisfied: idna<3,>=2.5 in /Users/****/.local/lib/python3.7/site-packages (from requests<3,>=2.21.0->tensorboard~=2.5->tensorflow) (2.10)
Requirement already satisfied: chardet<5,>=3.0.2 in /Users/****/.local/lib/python3.7/site-packages (from requests<3,>=2.21.0->tensorboard~=2.5->tensorflow) (4.0.0)
Requirement already satisfied: oauthlib>=3.0.0 in /Users/****/.local/lib/python3.7/site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard~=2.5->tensorflow) (3.1.0)
Requirement already satisfied: zipp>=0.5 in /Users/****/.local/lib/python3.7/site-packages (from importlib-metadata->markdown>=2.6.8->tensorboard~=2.5->tensorflow) (3.4.1)
WARNING: Running pip as root will break packages and permissions. You should install packages reliably by using venv: https://pip.pypa.io/warnings/venv
> Requirement already satisfied: tensorflow in /Users/****/.local/lib/python3.7/site-packages (2.5.0)
インストールできてますよ
「Requirement already satisfied」は、要るもの既に入ってる、という意味
そうなんですか...
その、TensorFlowが呼び出せるか試したら
****:keras shobu$ python
Python 3.7.2 (default, Dec 29 2018, 00:00:04)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
2021-06-01 17:59:56.211310: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
こうなってしまい、できないのです。
良かったら教えて頂けませんか?
> This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
それも無視
参考
https://qiita.com/KEINOS/items/4c66eeda4347f8c13abb
参考で出していただいた、ことをしたいのですがこうなってしまい訳がわかりません。
何度も申し訳ございません。
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'tensorflow' has no attribute 'Session'
>>> print(sess.run(hello))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'sess' is not defined
>>>
> module 'tensorflow' has no attribute 'Session'
それは「TensorFlow 1.*」時代の書き方です
インストールしたのは2.5.0なので
https://qiita.com/robamimim/items/b96d99489aa1bbffaa42
古い書籍とか見てるのですか?
【追記】 すみません
私が参考に提示したWebページに、そう書いてあったのですね
失礼しました
本当にありがとうございます。
見ていた書籍は、2018年のいちばんやさしいディープラーニングというものです。
改めて自分の検索の仕方が下手くそなことがわかりました。
半日付き合ってくださり誠にありがとうございます。
よろしければベストアンサーになっていただきたいので、回答に何か書いていただけませんか?
今日は本当にありがとうございました。
> 見ていた書籍は、2018年のいちばんやさしいディープラーニング
これですね
http://www.sotechsha.co.jp/sp/1187/
その本に書いてあるのを実行したいなら、バーションを合わせた方がいいです
そうしないと、TensorFlow 1.*と2.*の仕様の違いで、エラー出まくります
と言っても、本ではTensorFlow 1.4を入れてますが、それは古すぎるので、1.*の最終バージョンと、Kerasもそれと一緒に使える最終バージョンを入れておくのが、無難だと思います
バージョン指定は、下記のようにやります
sudo pip install tensorflow==1.15.3
sudo pip install keras==2.3.1
バージョン番号の前の「=」(イコール)は、二つです
わざわざありがとうございます。
何から何まで親切に教えていただき誠にありがとうございます。
本当にありがとうございます。
https://teratail.com/questions/341681
まだ教えていただけるなら、Kerasがなぜできないのか教えていただけませんか?
あの後自分で調べてみたのですがわかりませんでした。
回答1件
あなたの回答
tips
プレビュー