无法加载张量流

时间:2018-08-27 03:39:20

标签: python tensorflow keras

我的代码只是在pycharm中执行:

import tensorflow as tf

我收到以下消息:

Traceback (most recent call last):
  File "/Users/peterwills/PyCharmProjects/Kaggle/Salt_pretrain/pretrain_model.py", line 1, in <module>
    import tensorflow as tf
  File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/__init__.py", line 28, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 81, in <module>
    from tensorflow.python import keras
  File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/python/keras/__init__.py", line 24, in <module>
    from tensorflow.python.keras import activations
  File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/python/keras/activations/__init__.py", line 22, in <module>
    from tensorflow.python.keras._impl.keras.activations import elu
  File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/python/keras/_impl/keras/__init__.py", line 21, in <module>
    from tensorflow.python.keras._impl.keras import activations
  File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/python/keras/_impl/keras/activations.py", line 23, in <module>
    from tensorflow.python.keras._impl.keras import backend as K
  File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/python/keras/_impl/keras/backend.py", line 38, in <module>
    from tensorflow.python.layers import base as tf_base_layers
  File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/python/layers/base.py", line 25, in <module>
    from tensorflow.python.keras.engine import base_layer
  File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/python/keras/engine/__init__.py", line 21, in <module>
    from tensorflow.python.keras.engine.base_layer import InputSpec
  File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 33, in <module>
    from tensorflow.python.keras import backend
  File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/python/keras/backend/__init__.py", line 22, in <module>
    from tensorflow.python.keras._impl.keras.backend import abs
ImportError: cannot import name 'abs'

我的张量流版本是1.9.0。 我的Keras版本是:2.2.2 ...都在水蟒中

我曾尝试按照其他地方的建议卸载张量流和protobuf,但无济于事。

有人可以建议吗?

1 个答案:

答案 0 :(得分:0)

我通过在anaconda中创建一个新的虚拟环境并重新安装张量流(以及许多其他无关的东西)来解决此问题。我同意很多,但“只能确保这一点”。