无法通过pip安装pdftopng:编译提示config.h文件缺失
问题:pip安装pdftopng时提示'config.h'文件找不到
使用pip 23.0.1安装pdftopng时出现编译失败,核心报错为fatal error: 'config.h' file not found,此前曾成功安装并正常使用该包。
错误日志
~/06-Projekte/PycharmProjects/sgf2eps % pip install pdftopng Collecting pdftopng Using cached pdftopng-0.1.0.tar.gz (11 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Collecting Click>=7.0 Using cached click-8.1.3-py3-none-any.whl (96 kB) Building wheels for collected packages: pdftopng Building wheel for pdftopng (pyproject.toml) ... error error: subprocess-exited-with-error × Building wheel for pdftopng (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [35 lines of output] running bdist_wheel running build running build_py creating build creating build/lib.macosx-13-x86_64-cpython-311 creating build/lib.macosx-13-x86_64-cpython-311/pdftopng copying src/pdftopng/__init__.py -> build/lib.macosx-13-x86_64-cpython-311/pdftopng copying src/pdftopng/__version__.py -> build/lib.macosx-13-x86_64-cpython-311/pdftopng running egg_info writing src/pdftopng.egg-info/PKG-INFO writing dependency_links to src/pdftopng.egg-info/dependency_links.txt writing requirements to src/pdftopng.egg-info/requires.txt writing top-level names to src/pdftopng.egg-info/top_level.txt reading manifest file 'src/pdftopng.egg-info/SOURCES.txt' writing manifest file 'src/pdftopng.egg-info/SOURCES.txt' copying src/pdftopng/pdftopng.cpp -> build/lib.macosx-13-x86_64-cpython-311/pdftopng running build_ext creating var creating var/folders creating var/folders/rf creating var/folders/rf/5wykxh413gg6djy1vmg0ypww0000gn creating var/folders/rf/5wykxh413gg6djy1vmg0ypww0000gn/T clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/usr/local/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c /var/folders/rf/5wykxh413gg6djy1vmg0ypww0000gn/T/tmpl6tvr13s.cpp -o var/folders/rf/5wykxh413gg6djy1vmg0ypww0000gn/T/tmpl6tvr13s.o -std=c++14 clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/usr/local/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c /var/folders/rf/5wykxh413gg6djy1vmg0ypww0000gn/T/tmpav4l0ebv.cpp -o var/folders/rf/5wykxh413gg6djy1vmg0ypww0000gn/T/tmpav4l0ebv.o -fvisibility=hidden building 'pdftopng.pdftopng' extension creating build/temp.macosx-13-x86_64-cpython-311 creating build/temp.macosx-13-x86_64-cpython-311/src creating build/temp.macosx-13-x86_64-cpython-311/src/pdftopng clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -DVERSION_INFO=\"0.1.0\" -Ilib/poppler -Ilib/poppler/fofi -Ilib/poppler/goo -Ilib/poppler/poppler -Ilib/poppler/build -Ilib/poppler/build/poppler -Ilib/poppler/utils -Ilib/poppler/build/utils -I/private/var/folders/rf/5wykxh413gg6djy1vmg0ypww0000gn/T/pip-build-env-xio3q4pz/overlay/lib/python3.11/site-packages/pybind11/include -I/usr/local/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c src/pdftopng/pdftopng.cpp -o build/temp.macosx-13-x86_64-cpython-311/src/pdftopng/pdftopng.o -O3 -Wall -shared -fPIC -stdlib=libc++ -mmacosx-version-min=10.7 -std=c++14 -fvisibility=hidden clang: warning: argument unused during compilation: '-shared' [-Wunused-command-line-argument] src/pdftopng/pdftopng.cpp:44:10: fatal error: 'config.h' file not found #include "config.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 pdftopng Failed to build pdftopng ERROR: Could not build wheels for pdftopng, which is required to install pyproject.toml-based projects
解决步骤
安装Poppler开发依赖:pdftopng编译时需要Poppler的头文件支持,先通过系统包管理器安装:
- macOS(Homebrew):
brew install poppler - Linux(Debian/Ubuntu):
sudo apt-get install libpoppler-dev
安装完成后重新执行
pip install pdftopng- macOS(Homebrew):
清理pip缓存:缓存的旧安装文件可能损坏,清理后重试安装:
pip cache purge pip install pdftopng修复编译工具链:macOS需确保Xcode命令行工具完整,执行以下命令安装或更新:
xcode-select --install手动指定Poppler路径:如果系统Poppler路径不在默认搜索范围,编译时手动指定头文件和库路径:
CFLAGS="-I$(brew --prefix poppler)/include" LDFLAGS="-L$(brew --prefix poppler)/lib" pip install pdftopng
内容的提问来源于stack exchange,提问作者Ulrich
相关产品推荐
相关产品推荐

