1
2
3
4
5
6
7
8
9
| >>> from tensorflow.contrib import rnn
ImportError: cannot import name rnn
>>> import tensorflow as tf
>>> from tf.contrib import rnn
ImportError: No module named tf.contrib
>>> print tf.__version__
0.8.0 |
>>> from tensorflow.contrib import rnn
ImportError: cannot import name rnn
>>> import tensorflow as tf
>>> from tf.contrib import rnn
ImportError: No module named tf.contrib
>>> print tf.__version__
0.8.0
表示tensorflow的装的版本太低了,至少要装0.9.0版,比如装这个版本:
1
2
3
4
5
6
7
| $ pip uninstall tensorflow
# Ubuntu/Linux 64-bit, CPU only, Python 2.7
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl
# Python 2
$ sudo pip install --upgrade $TF_BINARY_URL |
$ pip uninstall tensorflow
# Ubuntu/Linux 64-bit, CPU only, Python 2.7
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl
# Python 2
$ sudo pip install --upgrade $TF_BINARY_URL
详情见:https://stackoverflow.com/questions/38386824/how-to-update-tensorflow-to-support-tf-contrib
再一点,新版的tensorflow只支持python3了,所以其实最简单的装tensorflow的方法是:
1
2
3
| apt install pip3
pip3 install tensorflow |
apt install pip3
pip3 install tensorflow