Kamran Ansari
Kamran Ansari

Reputation: 23

Error in installing pyhdf using pip command in macos

I am trying to install pyhdf (https://pypi.org/project/pyhdf/) package using pip command in macos terminal, but I am facing the following error:

Collecting pyhdf
  Using cached pyhdf-0.11.3.tar.gz (146 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyhdf
  Building wheel for pyhdf (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for pyhdf (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [38 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-11.1-arm64-cpython-311
      creating build/lib.macosx-11.1-arm64-cpython-311/pyhdf
      copying pyhdf/V.py -> build/lib.macosx-11.1-arm64-cpython-311/pyhdf
      copying pyhdf/error.py -> build/lib.macosx-11.1-arm64-cpython-311/pyhdf
      copying pyhdf/HDF.py -> build/lib.macosx-11.1-arm64-cpython-311/pyhdf
      copying pyhdf/__init__.py -> build/lib.macosx-11.1-arm64-cpython-311/pyhdf
      copying pyhdf/VS.py -> build/lib.macosx-11.1-arm64-cpython-311/pyhdf
      copying pyhdf/six.py -> build/lib.macosx-11.1-arm64-cpython-311/pyhdf
      copying pyhdf/SD.py -> build/lib.macosx-11.1-arm64-cpython-311/pyhdf
      copying pyhdf/HC.py -> build/lib.macosx-11.1-arm64-cpython-311/pyhdf
      copying pyhdf/hdfext.py -> build/lib.macosx-11.1-arm64-cpython-311/pyhdf
      copying pyhdf/test_SD.py -> build/lib.macosx-11.1-arm64-cpython-311/pyhdf
      running egg_info
      writing pyhdf.egg-info/PKG-INFO
      writing dependency_links to pyhdf.egg-info/dependency_links.txt
      writing top-level names to pyhdf.egg-info/top_level.txt
      reading manifest file 'pyhdf.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      no previously-included directories found matching 'doc/_build'
      adding license file 'LICENSE'
      adding license file 'AUTHORS'
      writing manifest file 'pyhdf.egg-info/SOURCES.txt'
      copying pyhdf/hdfext.i -> build/lib.macosx-11.1-arm64-cpython-311/pyhdf
      copying pyhdf/hdfext_wrap.c -> build/lib.macosx-11.1-arm64-cpython-311/pyhdf
      running build_ext
      building 'pyhdf._hdfext' extension
      creating build/temp.macosx-11.1-arm64-cpython-311
      creating build/temp.macosx-11.1-arm64-cpython-311/pyhdf
      clang -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/kamran/anaconda3/include -arch arm64 -fPIC -O2 -isystem /Users/kamran/anaconda3/include -arch arm64 -I/private/var/folders/dx/c0jyd4_j1952tqyy_9_6bg0h0000gn/T/pip-build-env-1wj7gp28/overlay/lib/python3.11/site-packages/numpy/core/include -I/Users/kamran/anaconda3/include/python3.11 -c pyhdf/hdfext_wrap.c -o build/temp.macosx-11.1-arm64-cpython-311/pyhdf/hdfext_wrap.o -DNOSZIP
      pyhdf/hdfext_wrap.c:3677:10: fatal error: 'hdf.h' file not found
      #include "hdf.h"
               ^~~~~~~
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pyhdf
Failed to build pyhdf
ERROR: Could not build wheels for pyhdf, which is required to install pyproject.toml-based projects

This package was easily installed in windows and linux, but not working in macOS. Can anyone please provide a solution to this error?

Upvotes: 0

Views: 369

Answers (1)

Joey
Joey

Reputation: 59

You are missing the hdf.h header files on your system that are a dependency to build the wheel for pyhdf.

Try brew install hdf5 or brew install hdf

Then pip install pyhdf again.

Upvotes: 0

Related Questions