LoginSignup
4
2

More than 3 years have passed since last update.

63日め tensorflowをインストールしました。

Posted at

機械学習をかじってみるために、tensorflowをインストールしました。
pip install tensorflowでさくっとできると思ったのですが、あっちこっちにエラーがでて、所要時間2時間越え。事前にPyHamcrestwraptをインストールする必要があったのでした。

以下、備忘録です。

まずは pip install tensorflow

$ pip install tensorflow
Collecting tensorflow
(なんやかんやダウンロード)
ERROR: twisted 18.7.0 requires PyHamcrest>=1.9.0, which is not installed.
Installing collected packages: wrapt, astor, setuptools, markdown, cachetools, rsa, google-auth, requests, oauthlib, requests-oauthlib, google-auth-oauthlib, tensorboard, tensorflow
  Found existing installation: wrapt 1.10.11
ERROR: Cannot uninstall 'wrapt'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

PyHamcrest?

パイハムクレスト?おいしそうな名前です。
pip3 list でみるとインストールされてない。

pip install PyHamcrest でいけそう。
マッチャーオブジェクトってなんだろう???
大事そうなフレームワーク。
https://pypi.org/project/PyHamcrest/

$ pip install PyHamcrest
Collecting PyHamcrest
  Downloading https://files.pythonhosted.org/packages/9a/d5/d37fd731b7d0e91afcc84577edeccf4638b4f9b82f5ffe2f8b62e2ddc609/PyHamcrest-1.9.0-py2.py3-none-any.whl (52kB)
     |████████████████████████████████| 61kB 1.3MB/s 
Requirement already satisfied: six in /anaconda3/lib/python3.7/site-packages (from PyHamcrest) (1.11.0)
Requirement already satisfied: setuptools in /anaconda3/lib/python3.7/site-packages (from PyHamcrest) (40.2.0)
Installing collected packages: PyHamcrest
Successfully installed PyHamcrest-1.9.0

二回めのpip install tensorflow

$ pip install tensorflow
Collecting tensorflow
  Using cached https://files.pythonhosted.org/packages/2c/72/6b3264aa2889b7dde7663464b99587d95cd6a5f3b9b30181f14d78a63e64/tensorflow-2.0.0-cp37-cp37m-macosx_10_11_x86_64.whl
Requirement already satisfied:
(二回めだからか、ダウンロードされずにどんどんインストールがすすむ)
ERROR: Cannot uninstall 'wrapt'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

PyHamcrestはクリア。
しかしまだエラーが残っています。

ERROR: Cannot uninstall 'wrapt’.

これは一体なんなんだ???

wraptとは?

「wrapt は Graham Dumpleton (mod_wsgi の作者) による、ラッパー記述を補助してくれるライブラリです。」
https://qiita.com/yoichi22/items/df42d1f038ff2423e37b

distutilsとは?

distutils パッケージは、現在インストールされている Python に追加するためのモジュール構築、および実際のインストールを支援します。
https://docs.python.org/ja/3/library/distutils.html

これらのパッケージがなんだか調子悪いということ???

condaとは?

Anaconda には conda コマンドがインストールされており、パッケージのインストールや、実行環境の作成・切り替えなどを行えます。
https://www.python.jp/install/anaconda/conda.html

再度、エラーメッセージで検索してみる。

ERROR: Cannot uninstall 'wrapt'. during upgrade 
https://github.com/tensorflow/tensorflow/issues/30191

似たようなお悩みと解決した方法が。

condaをアップデート
condaの’wrapt’をアップデート
・pipでwraptをアップデート、リムーブ、無視(ignore)

wraptをどうにかすればよさそうです!

conda install wrapt

$ conda install wrapt
Solving environment: done

## Package Plan ##

  environment location: /anaconda3

  added / updated specs: 
    - wrapt

The following packages will be downloaded:
ご一緒にこちらもダウンロードしますね→ずらーっと大量!こんなにたくさん!?

The following NEW packages will be INSTALLED:
こちらのパッケージがインストールされます→ずらずらずら。Python関係がなんでも新しくなるらしい。大丈夫かな???

Proceed ([y]/n)? y
よろしいですか?
→怖いのでバックアップを取ってもう一度ここに来る。
 各種ダウンロードしてインストールすること15分。
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(base) $ 
これでいいのかな???

三回め

$ pip install tensorflow
Collecting tensorflow
(中略)
Installing collected packages: oauthlib, requests-oauthlib, rsa, cachetools, google-auth, google-auth-oauthlib, markdown, numpy, absl-py, protobuf, grpcio, tensorboard, opt-einsum, h5py, keras-applications, gast, tensorflow-estimator, keras-preprocessing, termcolor, google-pasta, astor, tensorflow
Successfully installed absl-py-0.8.1 astor-0.8.0 cachetools-3.1.1 gast-0.2.2 google-auth-1.7.2 google-auth-oauthlib-0.4.1 google-pasta-0.1.8 grpcio-1.25.0 h5py-2.10.0 keras-applications-1.0.8 keras-preprocessing-1.1.0 markdown-3.1.1 numpy-1.17.4 oauthlib-3.1.0 opt-einsum-3.1.0 protobuf-3.11.1 requests-oauthlib-1.3.0 rsa-4.0 tensorboard-2.0.2 tensorflow-2.0.0 tensorflow-estimator-2.0.1 termcolor-1.1.0
$

pip install tensorflow` できたっぽい。
試してみます。

$ python3

>>> import tensorflow as tf
>>> hello = tf.constant("Hello")
>>> tf.print(hello)
Hello
>>> 
>>> exit()

ふう、うごいた。

(所要時間 2時間)

4
2
0

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
4
2