2

我对python完全陌生,在运行我的程序时出现错误..

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/tensorflow_hub/tf_v1.py", line 29, in <module>
    from tensorflow.compat.v1 import *  
ImportError: No module named 'tensorflow.compat'

During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "train.py", line 5, in <module>
        import tensorflow_hub as hub
      File "/usr/local/lib/python3.5/dist-packages/tensorflow_hub/__init__.py", line 30, in <module>
        from tensorflow_hub.estimator import LatestModuleExporter
      File "/usr/local/lib/python3.5/dist-packages/tensorflow_hub/estimator.py", line 25, in <module>
        from tensorflow_hub import tf_utils
      File "/usr/local/lib/python3.5/dist-packages/tensorflow_hub/tf_utils.py", line 28, in <module>
        from tensorflow_hub import tf_v1
      File "/usr/local/lib/python3.5/dist-packages/tensorflow_hub/tf_v1.py", line 63, in <module>
        from tensorflow import regex_replace
    ImportError: cannot import name 'regex_replace'

train.py

import os
import numpy as np
import pandas as pd
import tensorflow as tf
import tensorflow_hub as hub
import json
import pickle
import urllib

from sklearn.preprocessing import LabelBinarizer

print(tf.__version__)

没有导入tensorflow_hub它工作正常.. 但对于我的算法它必须.. 我搜索了很多链接,但我无法得到正确的解决方案。请给我一个小提示来解决我的问题..

4

1 回答 1

4

尝试升级 tensorflow 模块。它对我有用。使用以下命令升级。
pip install --upgrade tensorflow

于 2019-03-31T07:12:41.423 回答