Error when install h5py on my Windows11, Visual Studio Code, Python 3.10.4, 64-bt

Question:

I meet error when install h5py on my Windows11, Visual Studio Code, Python 3.10.4, 64-bt

Please see error detail at the very end of the post

My working process as below (i.e., the way I tired to solve the error):

1st: Upgrade pip, wheel and setuptools: They already satisfied as shown below

PS C:usersappdatalocalprogramspythonpython310libsite-packages> pip3 install --upgrade pip
>>
Requirement already satisfied: pip in c:usersappdatalocalprogramspythonpython310libsite-packages (22.1.2)
PS C:usersappdatalocalprogramspythonpython310libsite-packages> pip install --upgrade wheel          
Requirement already satisfied: wheel in c:usersappdatalocalprogramspythonpython310libsite-packages (0.37.1)
PS C:usersappdatalocalprogramspythonpython310libsite-packages>  pip install --upgrade setuptools
Requirement already satisfied: setuptools in c:usersappdatalocalprogramspythonpython310libsite-packages (63.2.0)

2nd: Installing virtualenv: Already downloaded

Requirement already satisfied: virtualenv in c:usersappdataroamingpythonpython310site-packages (20.15.1)
Requirement already satisfied: six<2,>=1.9.0 in c:usersappdatalocalprogramspythonpython310libsite-packages (from virtualenv) (1.15.0)
Requirement already satisfied: platformdirs<3,>=2 in c:usersappdataroamingpythonpython310site-packages (from virtualenv) (2.5.2)
Requirement already satisfied: filelock<4,>=3.2 in c:usersappdataroamingpythonpython310site-packages (from virtualenv) (3.7.1)
Requirement already satisfied: distlib<1,>=0.3.1 in c:usersappdataroamingpythonpython310site-packages (from virtualenv) (0.3.5)

3rd install C++ build tool: Already download and ready to use as shown below
enter image description here

4th try install package through terminal: Get error
pip install h5py==3.1.0 and pip install --no-binary=h5py h5py==3.1.0

Asked By: Flora

||

Answers:

A quick way to resolve the issue without troubleshooting.

Please follow the steps and update the same.

  1. Uninstall all the packages you are currently having problems with.
  2. Create a virtual environment: How to create a virtual environment link here
  3. Install all packages inside the virtual environment.
  4. Test by importing them and see if it works.
Answered By: Geg

h5py version 3.1 requires numpy=1.19.3 which does not have wheels for python 3.10, only up to 3.9 and building numpy from source on Windows is not easy because you would need to take care of quite some dependencies which you would need to build manually before (see e.g. libraries mkl_rt not found in your error message).

I would therefore suggest to either:

  • downgrade your python version, then install all versions as set in yur question
  • consider if a newer version of h5py (with a different numpy requirement) would also work for you
  • Try pip install --no-deps h5py==3.1.0 and install a numpy version compatible with your python separately. This has a high chance of not working, though.

The first option is probably the best, since you most likely have reasons why you need that specific h5py version. If you find yourself often needing different python versions for different projects, consider using a virtual environment manager like conda

Answered By: FlyingTeller
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.