pythonpiph5py

Cannot install h5py python package


I am not able to install h5py using

pip install h5py

I get the following output:

Defaulting to user installation because normal site-packages is not writeable
Collecting h5py
  Using cached h5py-3.10.0.tar.gz (403 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [59 lines of output]
      C:\Users\elizam\AppData\Local\Temp\pip-install-zwc9_8m6\h5py_dc3f272536414b6db5e16fbf153e2ade\api_gen.py:63: SyntaxWarning: invalid escape sequence '\.'
        PATTERN = re.compile("""(?P<mpi>(MPI)[ ]+)?
      C:\Users\elizam\AppData\Local\Temp\pip-install-zwc9_8m6\h5py_dc3f272536414b6db5e16fbf153e2ade\api_gen.py:76: SyntaxWarning: invalid escape sequence '\*'
        SIG_PATTERN = re.compile("""
      C:\Users\elizam\AppData\Local\Temp\pip-install-zwc9_8m6\h5py_dc3f272536414b6db5e16fbf153e2ade\setup_configure.py:46: SyntaxWarning: invalid escape sequence '\d'
        m = re.match('(\d+)\.(\d+)\.(\d+)$', s)
      running egg_info
      writing h5py.egg-info\PKG-INFO
      writing dependency_links to h5py.egg-info\dependency_links.txt
      writing requirements to h5py.egg-info\requires.txt
      writing top-level names to h5py.egg-info\top_level.txt
      reading manifest file 'h5py.egg-info\SOURCES.txt'
      Traceback (most recent call last):
        File "C:\Users\elizam\AppData\Roaming\Python\Python312-32\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "C:\Users\elizam\AppData\Roaming\Python\Python312-32\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\elizam\AppData\Roaming\Python\Python312-32\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\elizam\AppData\Local\Temp\pip-build-env-xul42mh6\overlay\Lib\site-packages\setuptools\build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\elizam\AppData\Local\Temp\pip-build-env-xul42mh6\overlay\Lib\site-packages\setuptools\build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "C:\Users\elizam\AppData\Local\Temp\pip-build-env-xul42mh6\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 68, in <module>
        File "C:\Users\elizam\AppData\Local\Temp\pip-build-env-xul42mh6\overlay\Lib\site-packages\setuptools\__init__.py", line 103, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\elizam\AppData\Local\Temp\pip-build-env-xul42mh6\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 185, in setup
          return run_commands(dist)
                 ^^^^^^^^^^^^^^^^^^
        File "C:\Users\elizam\AppData\Local\Temp\pip-build-env-xul42mh6\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 201, in run_commands
          dist.run_commands()
        File "C:\Users\elizam\AppData\Local\Temp\pip-build-env-xul42mh6\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "C:\Users\elizam\AppData\Local\Temp\pip-build-env-xul42mh6\overlay\Lib\site-packages\setuptools\dist.py", line 963, in run_command
          super().run_command(command)
        File "C:\Users\elizam\AppData\Local\Temp\pip-build-env-xul42mh6\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
          cmd_obj.run()
        File "C:\Users\elizam\AppData\Local\Temp\pip-build-env-xul42mh6\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 321, in run
          self.find_sources()
        File "C:\Users\elizam\AppData\Local\Temp\pip-build-env-xul42mh6\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 329, in find_sources
          mm.run()
        File "C:\Users\elizam\AppData\Local\Temp\pip-build-env-xul42mh6\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 550, in run
          self.add_defaults()
        File "C:\Users\elizam\AppData\Local\Temp\pip-build-env-xul42mh6\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 595, in add_defaults
          self.read_manifest()
        File "C:\Users\elizam\AppData\Local\Temp\pip-build-env-xul42mh6\overlay\Lib\site-packages\setuptools\command\sdist.py", line 203, in read_manifest
          self.filelist.append(line)
        File "C:\Users\elizam\AppData\Local\Temp\pip-build-env-xul42mh6\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 487, in append
          path = convert_path(item)
                 ^^^^^^^^^^^^^^^^^^
        File "C:\Users\elizam\AppData\Local\Temp\pip-build-env-xul42mh6\overlay\Lib\site-packages\setuptools\_distutils\util.py", line 139, in convert_path
          raise ValueError("path '%s' cannot be absolute" % pathname)
      ValueError: path '/home/takluyver/Code/h5py/h5py/_conv.c' cannot be absolute
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

I've tried to uninstall other python packages, still get the same problem. I've also tried creating a virtual environment, still get the same problem. Also tried upgrading pip and installing latest versions of setuptools and wheels. Stll get the same error.

Also tried to install some older versions of h5py, but then I get the same or some other error.


Solution

  • I solved the issue by using python version 3.10 instead of 3.12.