AttributeError:类型对象'h5py.h5r.Reference'没有属性'__reduce_cython __'

时间:2019-12-17 03:00:43

标签: python keras conda h5py

我正在使用python 3.6,Tensorflow 1.3,Keras 2.1.2 我正在导入Resnet50,但出现此错误“ ImportError:load_model需要h5py”,因此我使用了 康达安装h5py 但是然后我知道安装的h5py版本是2.9.0 enter image description here

时出现了此错误

1 个答案:

答案 0 :(得分:0)

对此错误有解决方案吗?

当尝试导入tensorflow(v2.0.0)和Python 3.7.3时我得到的是相同的东西

跟踪:

>>> import tensorflow as tf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\*\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "C:\Users\*\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 82, in <module>
    from tensorflow.python import keras
  File "C:\Users\*\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\keras\__init__.py", line 25, in <module>
    from tensorflow.python.keras import applications
  File "C:\Users\*\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\keras\applications\__init__.py", line 26, in <module>
    from tensorflow.python.keras import layers
  File "C:\Users\*\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\keras\layers\__init__.py", line 29, in <module>
    from tensorflow.python.keras.layers.advanced_activations import LeakyReLU
  File "C:\Users\*\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\keras\layers\advanced_activations.py", line 27, in <module>
    from tensorflow.python.keras.utils import tf_utils
  File "C:\Users\*\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\keras\utils\__init__.py", line 38, in <module>
    from tensorflow.python.keras.utils.multi_gpu_utils import multi_gpu_model
  File "C:\Users\*\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\keras\utils\multi_gpu_utils.py", line 22, in <module>
    from tensorflow.python.keras.engine.training import Model
  File "C:\Users\*\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\keras\engine\training.py", line 42, in <module>
    from tensorflow.python.keras.engine.network import Network
  File "C:\Users\potvin\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\keras\engine\network.py", line 40, in <module>
    from tensorflow.python.keras.engine import saving
  File "C:\Users\*\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\keras\engine\saving.py", line 38, in <module>
    import h5py
  File "C:\Users\*\AppData\Local\Continuum\anaconda3\lib\site-packages\h5py\__init__.py", line 36, in <module>
    from ._conv import register_converters as _register_converters
  File "h5py\h5r.pxd", line 21, in init h5py._conv
  File "h5py\h5r.pyx", line 145, in init h5py.h5r
AttributeError: type object 'h5py.h5r.Reference' has no attribute '__reduce_cython__'

编辑:我能够通过重新启动内核来解决此问题。