我正在尝试在 macos 终端中使用 pip 命令安装 pyhdf (https://pypi.org/project/pyhdf/) 包,但我遇到以下错误:
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
该软件包可以轻松安装在 Windows 和 Linux 中,但无法在 macOS 中运行。谁能提供此错误的解决方案吗?
您的系统上缺少
hdf.h
头文件,这些文件是构建 pyhdf 轮子的依赖项。
尝试
brew install hdf5
或brew install hdf
然后再次
pip install pyhdf
。