I am trying to install h5py on my macbook m1. I first ran brew install hdf5
as described in the documentation.
Then I ran pip3 install h5py
, but this always leads to the following error message.
I also tried the solution from this post (How to install h5py (needed for Keras) on MacOS with M1?), but it ended in the same result.
Error compiling Cython file:
------------------------------------------------------------
...
"""(UINT index) => STRING
Get the directory path at the given index (starting from 0) in the
plugin search path. Returns a Python bytes object.
"""
cpdef size_t n
^
------------------------------------------------------------
h5py/h5pl.pyx:64:14: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
Error compiling Cython file:
------------------------------------------------------------
...
Get the directory path at the given index (starting from 0) in the
plugin search path. Returns a Python bytes object.
"""
cpdef size_t n
cpdef char* buf = NULL
^
------------------------------------------------------------
h5py/h5pl.pyx:65:14: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
Error compiling Cython file:
------------------------------------------------------------
...
cpdef size():
"""() => UINT
Get the number of directories currently in the plugin search path.
"""
cpdef unsigned int n = 0
^
------------------------------------------------------------
h5py/h5pl.pyx:80:14: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/y4/x78nk9h91fz6gtdc549t55g00000gn/T/pip-install-agzrcn_9/h5py_07ca596659e44c58afabe948244bd411/setup.py", line 140, in <module>
setup(
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/__init__.py", line 145, in setup
return distutils.core.setup(**attrs)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/core.py", line 148, in setup
dist.run_commands()
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/command/install.py", line 561, in run
self.run_command('build')
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/private/var/folders/y4/x78nk9h91fz6gtdc549t55g00000gn/T/pip-install-agzrcn_9/h5py_07ca596659e44c58afabe948244bd411/setup_build.py", line 207, in run
self.extensions = cythonize(self._make_extensions(config),
File "/private/var/folders/y4/x78nk9h91fz6gtdc549t55g00000gn/T/pip-install-agzrcn_9/h5py_07ca596659e44c58afabe948244bd411/.eggs/Cython-3.0.0a9-py3.8.egg/Cython/Build/Dependencies.py", line 1116, in cythonize
cythonize_one(*args)
File "/private/var/folders/y4/x78nk9h91fz6gtdc549t55g00000gn/T/pip-install-agzrcn_9/h5py_07ca596659e44c58afabe948244bd411/.eggs/Cython-3.0.0a9-py3.8.egg/Cython/Build/Dependencies.py", line 1283, in cythonize_one
raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: /private/var/folders/y4/x78nk9h91fz6gtdc549t55g00000gn/T/pip-install-agzrcn_9/h5py_07ca596659e44c58afabe948244bd411/h5py/h5pl.pyx
----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Developer/CommandLineTools/usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/y4/x78nk9h91fz6gtdc549t55g00000gn/T/pip-install-agzrcn_9/h5py_07ca596659e44c58afabe948244bd411/setup.py'"'"'; __file__='"'"'/private/var/folders/y4/x78nk9h91fz6gtdc549t55g00000gn/T/pip-install-agzrcn_9/h5py_07ca596659e44c58afabe948244bd411/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/y4/x78nk9h91fz6gtdc549t55g00000gn/T/pip-record-b42l5c9z/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /Users/adrianwestphal/Library/Python/3.8/include/python3.8/h5py Check the logs for full command output.