ilovepython3
2022-03-29 21:49
采纳率: 100%
浏览 50

导入tensorflow报错

问题遇到的现象和发生背景

导入后报错

问题相关代码,请勿粘贴截图
import sys
import os
import numpy as np
import cv2
import tensorflow as tf
from sklearn.model_selection import train_test_split

运行结果及报错内容
Traceback (most recent call last):
  File "D:\eat\Anaconda\envs\pytorch\lib\site-packages\tensorflow\python\keras\engine\training.py", line 53, in <module>
    from tensorflow.python.keras.saving import hdf5_format
  File "D:\eat\Anaconda\envs\pytorch\lib\site-packages\tensorflow\python\keras\saving\hdf5_format.py", line 41, in <module>
    import h5py
  File "D:\eat\Anaconda\envs\pytorch\lib\site-packages\h5py\__init__.py", line 34, in <module>
    from . import version
  File "D:\eat\Anaconda\envs\pytorch\lib\site-packages\h5py\version.py", line 17, in <module>
    from . import h5 as _h5
  File "h5py\h5.pyx", line 41, in init h5py.h5

AttributeError: type object 'h5py.h5.H5PYConfig' has no attribute '__reduce_cython__'

我的解答思路和尝试过的方法

在网上也找过方法,说存在多个tensorflow,我看了,没有
然后说版本不兼容,我也不知道怎么改
也有试过这个:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
替换:
import tensorflow as tf
也不起作用

我想要达到的结果

能够正确导入并且运行不报错

1条回答 默认 最新

相关推荐 更多相似问题