ModuleNotFoundError: No module named ‘tensorflow.python‘

(django) D:\pycharm\homework\icc\centernet-keras-main>python predict.py
Using TensorFlow backend.
Traceback (most recent call last):
  File "predict.py", line 12, in 
    from keras.layers import Input
  File "C:\Users\miao\Anaconda3\envs\django\lib\site-packages\keras\__init__.py", line 3, in 
    from . import utils
  File "C:\Users\miao\Anaconda3\envs\django\lib\site-packages\keras\utils\__init__.py", line 6, in 
    from . import conv_utils
  File "C:\Users\miao\Anaconda3\envs\django\lib\site-packages\keras\utils\conv_utils.py", line 9, in 
    from .. import backend as K
  File "C:\Users\miao\Anaconda3\envs\django\lib\site-packages\keras\backend\__init__.py", line 1, in 
    from .load_backend import epsilon
  File "C:\Users\miao\Anaconda3\envs\django\lib\site-packages\keras\backend\load_backend.py", line 89, in 
    from .tensorflow_backend import *
  File "C:\Users\miao\Anaconda3\envs\django\lib\site-packages\keras\backend\tensorflow_backend.py", line 6, in 
    from tensorflow.python.framework import ops as tf_ops
ModuleNotFoundError: No module named 'tensorflow.python'

上面是错误内容,原因是之前安装的时候,TensorFlow的cpu和gpu版本都安装了,然后预测的时候返现一直调用cpu,即使设置调用gpu也是不行,然后卸载了cpu版本,之后重新predict报错如上ModuleNotFoundError: No module named 'tensorflow.python'

解决方法:再把gpu版本也卸载掉,然后重新安装且只安装gpu版本
 

pip install tensorflow-gpu==xxx -i https://pypi.douban.com/simple

 

你可能感兴趣的:(keras,python,tensorflow,bug,tensorflow,深度学习)