导入Keras无效

时间:2018-07-31 14:33:09

标签: python keras jupyter-notebook

我正在做:

import keras

我收到一长串错误消息:

AttributeError                            Traceback (most recent call last)
<ipython-input-32-88d96843a926> in <module>()
 ----> 1 import keras

~\Anaconda3\envs\test_tensorflow\lib\site-packages\keras\__init__.py in <module>()
        1 from __future__ import absolute_import
        2 
  ----> 3 from . import utils
        4 from . import activations
        5 from . import applications

  ~\Anaconda3\envs\test_tensorflow\lib\site-packages\keras\utils\__init__.py 
  in <module>()
        3 from . import generic_utils
        4 from . import data_utils
        ----> 5 from . import io_utils
        6 from . import conv_utils
        7 

 ~\Anaconda3\envs\test_tensorflow\lib\site-packages\keras\utils\io_utils.py in <module>()
         9 import six
         10 try:
         ---> 11     import h5py
         12 except ImportError:
         13     h5py = None

  ~\Anaconda3\envs\test_tensorflow\lib\site-packages\h5py\__init__.py in <module>()
          32         raise
          33 
          ---> 34 _errors.silence_errors()
          35 
          36 from ._conv import register_converters as _register_converters

          AttributeError: module 'h5py._errors' has no attribute 'silence_errors'

有人知道如何解决它吗?

在Windows 10上工作并使用Jupyter Notebook

2 个答案:

答案 0 :(得分:0)

尝试使用以下方法卸载并重新安装h5py:

pip uninstall h5py
pip install h5py

答案 1 :(得分:-1)

您可能需要直接导入tensorflow

尝试

import tensorflow 

在您之前

import keras