即使我安装了最新版本,tf.VERSION总是1.6.0

时间:2018-04-18 04:17:39

标签: tensorflow google-colaboratory

请帮我解决问题 - 我使用Google的Colaboratory运行tensor_hub示例文本分类与TF-Hub,它需要的版本晚于1.7.0,但我安装的版本是1.8.0。

# Install the latest Tensorflow version.
!pip install --quiet "tensorflow>=1.7"
# Install TF-Hub.
!pip install tensorflow-hub

import tensorflow as tf
import tensorflow_hub as hub
import matplotlib.pyplot as plt
import numpy as np
import os
import pandas as pd
import re
import seaborn as sns



RuntimeErrorTraceback (most recent call last) <ipython-input-20-48e1bdaa8642> in <module>()
      1 import tensorflow as tf
----> 2 import tensorflow_hub as hub
      3 import matplotlib.pyplot as plt
      4 import numpy as np
      5 import os

/usr/local/lib/python2.7/dist-packages/tensorflow_hub/__init__.py in <module>()
     63 
     64 # Comment/uncomment to skip checking the TensorFlow version.
---> 65 _check_tensorflow_version(tf.VERSION)
     66 
     67 # Used by doc generation script.

/usr/local/lib/python2.7/dist-packages/tensorflow_hub/__init__.py in
_check_tensorflow_version(version)
     60       "TensorFlow Hub depends on 'tf-nightly' build after %s or "
     61       "'tensorflow~=%s'. Found tf.VERSION = %s" % (
---> 62           _NIGHTLY_VERSION, _MAIN_VERSION, version))
     63 
     64 # Comment/uncomment to skip checking the TensorFlow version.

RuntimeError: TensorFlow Hub depends on 'tf-nightly' build after 20180308 or 'tensorflow~=1.7'. Found tf.VERSION = 1.6.0

2 个答案:

答案 0 :(得分:2)

好消息:TF 1.7现在默认可用。 :)

你遇到的根本问题就是python缓存sys.modules中加载的模块 - 重新导入模块在重启过程之前不会获取新版本,正如Korakot指出的那样。

答案 1 :(得分:1)

您可能需要重新启动运行时。

menu > Runtime > Restart runtime...