tf.VERSION 始终是 1.6.0 即使我安装了最新版本

tf.VERSION is always 1.6.0 even though I installed the latest version

请帮我解决这个问题-我使用Google的Colaboratory来运行 tensor_hub example Text classification with 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

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

menu > Runtime > Restart runtime...

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

您遇到的根本问题只是 python 在 sys.modules 中缓存加载的模块——重新导入模块在您重新启动进程之前不会获取新版本,因为Korakot 指出。