question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fails to build from source on MacOS 11 + M1

See original GitHub issue
  • Operating System: MacOS 11.2
  • Python Version: 3.9.1
  • h5py version: 3.1.0
  • HDF5 version: 1.12.0

Attempting to install h5py via pip fails for ARM Macs; there is no prebuilt wheel for this platform, so pip attempts to build h5py from source. However, this fails because it attempts to use Numpy 1.19.3 (when on Python 3.9), but Numpy 1.19.3 does not build on M1 Macs out of the box (build log: h5py_build_fail.log).

If you modify setup.py so that h5py builds against Numpy 1.20.1 instead (which works on M1 Macs), h5py builds successfully.

Dumb example patch that fixes the build but isn’t intended to be actually merged:

diff --git a/setup.py b/setup.py
index cc583bc9..9c0400cc 100755
--- a/setup.py
+++ b/setup.py
@@ -29,7 +29,7 @@ NUMPY_MIN_VERSIONS = [
     # Numpy    Python
     ('1.14.5', "=='3.7'"),
     ('1.17.5', "=='3.8'"),
-    ('1.19.3', ">='3.9'"),
+    ('1.20.1', ">='3.9'"),
 ]

 # these are required to use h5py

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

14reactions
jiegeccommented, Jun 29, 2021

I found an alternative solution:

HDF5_DIR=/opt/homebrew/opt/hdf5 pip3 install --no-build-isolation h5py
7reactions
craigvandencommented, Apr 6, 2022

I have found that pip install only works if you have installed hdf5 separately first on the Mac M1. This was possible through brew but not pip.

Steps:

brew install hdf5
export HDF5_DIR=<path/to/homebrew/Cellar/hdf5/version>
pip install h5py
Read more comments on GitHub >

github_iconTop Results From Across the Web

Build failure on Apple Silicon M1 Mac Mini - Compiler
Hi, I'm seeing a build failure on an Apple Silicon Mac Mini that I'm not seeing on my Intel MacBook Pro. (Both checkouts...
Read more >
M1 Mac: Cannot build packages requiring compilation - General
Thankfully I can install package binaries or from source when compilation is not required. But I have tried many things to no real...
Read more >
Not Able to Build Some Versions of Python on M1 at 12.3.1
I trying to build older version of python such as 3.6, 3.7, 3.8 using pyenv and having build failures. I am on apple...
Read more >
cannot install edgeR on M1 Mac
I am trying to install Rhtslib on macOS Big Sur M1 using R 4.1.0. But I get the following error. And this problem...
Read more >
Fixing R Package Installation Errors in MacOS Big Sur ...
install.packages("RcppArmadillo", type = "source"). If you encounter an error like what is shown above, keep going. Step 3. Install a GNU gfortran build...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found