Pythonは3.x系なので、最新版のanaconda3-4.3.1 を。TensorFlowは、v1.1.0。
import tensorflow as tf hello = tf.constant("Hello, TensorFlow!") sess = tf.Session() print(sess.run(hello))
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) <ipython-input-1-febf9334bd31> in <module>() ----> 1 import tensorflow as tf 2 hello = tf.constant("Hello, TensorFlow!") 3 sess = tf.Session() 4 print(sess.run(hello)) ModuleNotFoundError: No module named 'tensorflow'
TensorFlowが動きません!
いろいろ調べたら、anaconda3-4.3.1をインストールしたら、
ローカルにPython 3.6がインストールされて、
TensorFlowがPython 3.6をサポートしていなくて、3.5じゃないとだめだと。
ローカルにPython 3.6がインストールされて、
TensorFlowがPython 3.6をサポートしていなくて、3.5じゃないとだめだと。
うーん、だめじゃん。。。。
とりあえず、anaconda3-4.1.0 をインストールして、
Ubuntu Linux に TensorFlow をインストールをやってみました。
そしたら、できましたよ。 TensorFlow も動きましたよ。
上記の設定後、
% cd ~/DeepLearning/jupyter % source activate tensorflow % jupyter notebookで、jupyter notebook を起動し、Chromeで、
http://localhost:8888にアクセスし、
import tensorflow as tf hello = tf.constant("Hello, TensorFlow!") sess = tf.Session() print(sess.run(hello))で、Shift + Return をしてら、
b'Hello, TensorFlow!'
と表示され、TensorFlow が動きました。
% source deactivateで、終了する。
で、run_jupyter.sh というコマンドにしておきました。
#!/bin/bash source activate tensorflow jupyter notebook source deactivate
あー、長かった。