import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/junyi/anaconda3/envs/myenv/lib/python3.6/site-packages/tensorflow/__init__.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/home/junyi/anaconda3/envs/myenv/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 83, in <module>
from tensorflow.python import keras
File "/home/junyi/anaconda3/envs/myenv/lib/python3.6/site-packages/tensorflow/python/keras/__init__.py", line 26, in <module>
from tensorflow.python.keras import activations
File "/home/junyi/anaconda3/envs/myenv/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 "/home/junyi/anaconda3/envs/myenv/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 "/home/junyi/anaconda3/envs/myenv/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 "/home/junyi/anaconda3/envs/myenv/lib/python3.6/site-packages/tensorflow/python/keras/_impl/keras/backend.py", line 37, in <module>
from tensorflow.python.layers import base as tf_base_layers
File "/home/junyi/anaconda3/envs/myenv/lib/python3.6/site-packages/tensorflow/python/layers/base.py", line 25, in <module>
from tensorflow.python.keras import backend
File "/home/junyi/anaconda3/envs/myenv/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'
解决方案,参考github:
先卸载protobuf, tensorflow, tensorflow-gpu
pip uninstall tensorflow tensorflow-gpu protobuf
再重新安装tensorflow-gpu
,会自动选择正确的依赖(我用的是ZJU源,-i
后面的可以去掉)
pip install tensorflow-gpu==1.14 -i https://mirrors.zju.edu.cn/pypi/web/simple