Skip to content
Advertisement

Errors in installing keras using pip?

I am trying to install Keras library using pip in windows 10. I have all the requirements installed, python>=3.8, pip>=20.0.0, NumPy, pandas, matplotlib, virtualenv. But I’m getting the following error.

(keras) C:Usersnamba>pip install keras
Collecting keras
  Using cached Keras-2.4.3-py2.py3-none-any.whl (36 kB)
Collecting h5py
  Using cached h5py-3.1.0.tar.gz (371 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
    Preparing wheel metadata ... done
Requirement already satisfied: numpy>=1.9.1 in c:usersnambakeraslibsite-packages (from keras) (1.19.4)
Collecting pyyaml
  Using cached PyYAML-5.3.1-cp38-cp38-win32.whl (199 kB)
Requirement already satisfied: scipy>=0.14 in c:usersnambakeraslibsite-packages (from keras) (1.5.4)
Building wheels for collected packages: h5py
  Building wheel for h5py (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:usersnambakerasscriptspython.exe' 'c:usersnambakeraslibsite-packagespip_vendorpep517_in_process.py' build_wheel 'C:UsersnambaAppDataLocalTemptmp0_p1fdyc'
       cwd: C:UsersnambaAppDataLocalTemppip-install-k9e6wdb4h5py
  Complete output (70 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating buildlib.win32-3.8
  creating buildlib.win32-3.8h5py
  copying h5pyh5py_warnings.py -> buildlib.win32-3.8h5py
  copying h5pyipy_completer.py -> buildlib.win32-3.8h5py
  copying h5pyversion.py -> buildlib.win32-3.8h5py
  copying h5py__init__.py -> buildlib.win32-3.8h5py
  creating buildlib.win32-3.8h5py_hl
  copying h5py_hlattrs.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hlbase.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hlcompat.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hldataset.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hldatatype.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hldims.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hlfiles.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hlfilters.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hlgroup.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hlselections.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hlselections2.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hlvds.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hl__init__.py -> buildlib.win32-3.8h5py_hl
  creating buildlib.win32-3.8h5pytests
  copying h5pytestscommon.py -> buildlib.win32-3.8h5pytests
  copying h5pytestsconftest.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_attribute_create.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_attrs.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_attrs_data.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_base.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_big_endian_file.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_completions.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_dataset.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_dataset_getitem.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_dataset_swmr.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_datatype.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_dimension_scales.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_dims_dimensionproxy.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_dtype.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_errors.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_file.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_file2.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_file_image.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_filters.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_group.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_h5.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_h5d_direct_chunk.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_h5f.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_h5p.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_h5pl.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_h5t.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_objects.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_selections.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_slicing.py -> buildlib.win32-3.8h5pytests
  copying h5pytests__init__.py -> buildlib.win32-3.8h5pytests
  creating buildlib.win32-3.8h5pytestsdata_files
  copying h5pytestsdata_files__init__.py -> buildlib.win32-3.8h5pytestsdata_files
  creating buildlib.win32-3.8h5pyteststest_vds
  copying h5pyteststest_vdstest_highlevel_vds.py -> buildlib.win32-3.8h5pyteststest_vds
  copying h5pyteststest_vdstest_lowlevel_vds.py -> buildlib.win32-3.8h5pyteststest_vds
  copying h5pyteststest_vdstest_virtual_source.py -> buildlib.win32-3.8h5pyteststest_vds
  copying h5pyteststest_vds__init__.py -> buildlib.win32-3.8h5pyteststest_vds
  copying h5pytestsdata_filesvlen_string_dset.h5 -> buildlib.win32-3.8h5pytestsdata_files
  copying h5pytestsdata_filesvlen_string_dset_utc.h5 -> buildlib.win32-3.8h5pytestsdata_files
  copying h5pytestsdata_filesvlen_string_s390x.h5 -> buildlib.win32-3.8h5pytestsdata_files
  running build_ext
  Loading library to get version: hdf5.dll
  error: Unable to load dependency HDF5, make sure HDF5 is installed properly
  error: Could not find module 'hdf5.dll' (or one of its dependencies). Try using the full path with constructor syntax.
  ----------------------------------------
  ERROR: Failed building wheel for h5py
Failed to build h5py
ERROR: Could not build wheels for h5py which use PEP 517 and cannot be installed directly

I thought this error was caused due to improper installation of h5py & hdf5. I tried installing them using pip install h5py but then I encountered the following error:

(keras) C:Usersnamba>pip install h5py
Collecting h5py
  Using cached h5py-3.1.0.tar.gz (371 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
    Preparing wheel metadata ... done
Requirement already satisfied: numpy>=1.17.5; python_version == "3.8" in c:usersnambakeraslibsite-packages (from h5py) (1.19.4)
Building wheels for collected packages: h5py
  Building wheel for h5py (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:usersnambakerasscriptspython.exe' 'c:usersnambakeraslibsite-packagespip_vendorpep517_in_process.py' build_wheel 'C:UsersnambaAppDataLocalTemptmpid2mdza_'
       cwd: C:UsersnambaAppDataLocalTemppip-install-yppxk_bmh5py
  Complete output (70 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating buildlib.win32-3.8
  creating buildlib.win32-3.8h5py
  copying h5pyh5py_warnings.py -> buildlib.win32-3.8h5py
  copying h5pyipy_completer.py -> buildlib.win32-3.8h5py
  copying h5pyversion.py -> buildlib.win32-3.8h5py
  copying h5py__init__.py -> buildlib.win32-3.8h5py
  creating buildlib.win32-3.8h5py_hl
  copying h5py_hlattrs.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hlbase.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hlcompat.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hldataset.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hldatatype.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hldims.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hlfiles.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hlfilters.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hlgroup.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hlselections.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hlselections2.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hlvds.py -> buildlib.win32-3.8h5py_hl
  copying h5py_hl__init__.py -> buildlib.win32-3.8h5py_hl
  creating buildlib.win32-3.8h5pytests
  copying h5pytestscommon.py -> buildlib.win32-3.8h5pytests
  copying h5pytestsconftest.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_attribute_create.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_attrs.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_attrs_data.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_base.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_big_endian_file.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_completions.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_dataset.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_dataset_getitem.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_dataset_swmr.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_datatype.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_dimension_scales.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_dims_dimensionproxy.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_dtype.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_errors.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_file.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_file2.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_file_image.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_filters.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_group.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_h5.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_h5d_direct_chunk.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_h5f.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_h5p.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_h5pl.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_h5t.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_objects.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_selections.py -> buildlib.win32-3.8h5pytests
  copying h5pyteststest_slicing.py -> buildlib.win32-3.8h5pytests
  copying h5pytests__init__.py -> buildlib.win32-3.8h5pytests
  creating buildlib.win32-3.8h5pytestsdata_files
  copying h5pytestsdata_files__init__.py -> buildlib.win32-3.8h5pytestsdata_files
  creating buildlib.win32-3.8h5pyteststest_vds
  copying h5pyteststest_vdstest_highlevel_vds.py -> buildlib.win32-3.8h5pyteststest_vds
  copying h5pyteststest_vdstest_lowlevel_vds.py -> buildlib.win32-3.8h5pyteststest_vds
  copying h5pyteststest_vdstest_virtual_source.py -> buildlib.win32-3.8h5pyteststest_vds
  copying h5pyteststest_vds__init__.py -> buildlib.win32-3.8h5pyteststest_vds
  copying h5pytestsdata_filesvlen_string_dset.h5 -> buildlib.win32-3.8h5pytestsdata_files
  copying h5pytestsdata_filesvlen_string_dset_utc.h5 -> buildlib.win32-3.8h5pytestsdata_files
  copying h5pytestsdata_filesvlen_string_s390x.h5 -> buildlib.win32-3.8h5pytestsdata_files
  running build_ext
  Loading library to get version: hdf5.dll
  error: Unable to load dependency HDF5, make sure HDF5 is installed properly
  error: Could not find module 'hdf5.dll' (or one of its dependencies). Try using the full path with constructor syntax.
  ----------------------------------------
  ERROR: Failed building wheel for h5py
Failed to build h5py
ERROR: Could not build wheels for h5py which use PEP 517 and cannot be installed directly

Please suggest any solutions to overcome these errors?

Advertisement

Answer

Sometimes it happens due to old version of pip

upgrade pip:

pip3 install --upgrade pip

then try again:

pip install h5py

Note: make sure your python3.8 is 64bit

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement