为什么pyheif在python导入时崩溃



当试图在python 3程序中导入'pyheif'时,我在下面得到了这个崩溃转储。

有人能解释一下如何成功导入这个包吗?我已经尝试了多个版本;"轮子";已安装等,搜索了Stack并进行了其他搜索,但尚未找到解决方法。

提前感谢!

Collecting pyheif
Using cached pyheif-0.5.1.tar.gz (17 kB)
Requirement already satisfied: cffi>=1.0.0 in /Users/user/venv/HEICToJPG/lib/python3.8/site-packages (from pyheif) (1.14.4)
Requirement already satisfied: pycparser in /Users/user/venv/HEICToJPG/lib/python3.8/site-packages (from cffi>=1.0.0->pyheif) (2.20)
Building wheels for collected packages: pyheif
Building wheel for pyheif (setup.py): started
Building wheel for pyheif (setup.py): finished with status 'error'
Running setup.py clean for pyheif
Failed to build pyheif
Installing collected packages: pyheif
Running setup.py install for pyheif: started
Running setup.py install for pyheif: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /Users/user/venv/HEICToJPG/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/ts/yxklk_lj3f32_q1kkljflz5h0000gn/T/pip-install-q3c_oaef/pyheif_88ea55c096834e3e8b4bbae48bc5e633/setup.py'"'"'; __file__='"'"'/private/var/folders/ts/yxklk_lj3f32_q1kkljflz5h0000gn/T/pip-install-q3c_oaef/pyheif_88ea55c096834e3e8b4bbae48bc5e633/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/ts/yxklk_lj3f32_q1kkljflz5h0000gn/T/pip-wheel-8kzdauau
cwd: /private/var/folders/ts/yxklk_lj3f32_q1kkljflz5h0000gn/T/pip-install-q3c_oaef/pyheif_88ea55c096834e3e8b4bbae48bc5e633/
Complete output (27 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.8
creating build/lib.macosx-10.9-x86_64-3.8/pyheif
copying pyheif/error.py -> build/lib.macosx-10.9-x86_64-3.8/pyheif
copying pyheif/constants.py -> build/lib.macosx-10.9-x86_64-3.8/pyheif
copying pyheif/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pyheif
copying pyheif/reader.py -> build/lib.macosx-10.9-x86_64-3.8/pyheif
copying pyheif/writer.py -> build/lib.macosx-10.9-x86_64-3.8/pyheif
creating build/lib.macosx-10.9-x86_64-3.8/pyheif/data
copying pyheif/data/version.txt -> build/lib.macosx-10.9-x86_64-3.8/pyheif/data
warning: build_py: byte-compiling is disabled, skipping.
running build_ext
generating cffi module 'build/temp.macosx-10.9-x86_64-3.8/_libheif_cffi.c'
creating build/temp.macosx-10.9-x86_64-3.8
building '_libheif_cffi' extension
creating build/temp.macosx-10.9-x86_64-3.8/build
creating build/temp.macosx-10.9-x86_64-3.8/build/temp.macosx-10.9-x86_64-3.8
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/usr/local/include -I/usr/include -I/Users/user/venv/HEICToJPG/include -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c build/temp.macosx-10.9-x86_64-3.8/_libheif_cffi.c -o build/temp.macosx-10.9-x86_64-3.8/build/temp.macosx-10.9-x86_64-3.8/_libheif_cffi.o
build/temp.macosx-10.9-x86_64-3.8/_libheif_cffi.c:570:15: fatal error: 'libheif/heif.h' file not found
#include "libheif/heif.h"
^~~~~~~~~~~~~~~~
1 error generated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for pyheif
ERROR: Command errored out with exit status 1:
command: /Users/user/venv/HEICToJPG/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/ts/yxklk_lj3f32_q1kkljflz5h0000gn/T/pip-install-q3c_oaef/pyheif_88ea55c096834e3e8b4bbae48bc5e633/setup.py'"'"'; __file__='"'"'/private/var/folders/ts/yxklk_lj3f32_q1kkljflz5h0000gn/T/pip-install-q3c_oaef/pyheif_88ea55c096834e3e8b4bbae48bc5e633/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/ts/yxklk_lj3f32_q1kkljflz5h0000gn/T/pip-record-phe46c7r/install-record.txt --single-version-externally-managed --compile --install-headers /Users/user/venv/HEICToJPG/include/site/python3.8/pyheif
cwd: /private/var/folders/ts/yxklk_lj3f32_q1kkljflz5h0000gn/T/pip-install-q3c_oaef/pyheif_88ea55c096834e3e8b4bbae48bc5e633/
Complete output (27 lines):
running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.8
creating build/lib.macosx-10.9-x86_64-3.8/pyheif
copying pyheif/error.py -> build/lib.macosx-10.9-x86_64-3.8/pyheif
copying pyheif/constants.py -> build/lib.macosx-10.9-x86_64-3.8/pyheif
copying pyheif/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pyheif
copying pyheif/reader.py -> build/lib.macosx-10.9-x86_64-3.8/pyheif
copying pyheif/writer.py -> build/lib.macosx-10.9-x86_64-3.8/pyheif
creating build/lib.macosx-10.9-x86_64-3.8/pyheif/data
copying pyheif/data/version.txt -> build/lib.macosx-10.9-x86_64-3.8/pyheif/data
warning: build_py: byte-compiling is disabled, skipping.
running build_ext
generating cffi module 'build/temp.macosx-10.9-x86_64-3.8/_libheif_cffi.c'
creating build/temp.macosx-10.9-x86_64-3.8
building '_libheif_cffi' extension
creating build/temp.macosx-10.9-x86_64-3.8/build
creating build/temp.macosx-10.9-x86_64-3.8/build/temp.macosx-10.9-x86_64-3.8
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/usr/local/include -I/usr/include -I/Users/user/venv/HEICToJPG/include -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c build/temp.macosx-10.9-x86_64-3.8/_libheif_cffi.c -o build/temp.macosx-10.9-x86_64-3.8/build/temp.macosx-10.9-x86_64-3.8/_libheif_cffi.o
build/temp.macosx-10.9-x86_64-3.8/_libheif_cffi.c:570:15: fatal error: 'libheif/heif.h' file not found
#include "libheif/heif.h"
^~~~~~~~~~~~~~~~
1 error generated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /Users/user/venv/HEICToJPG/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/ts/yxklk_lj3f32_q1kkljflz5h0000gn/T/pip-install-q3c_oaef/pyheif_88ea55c096834e3e8b4bbae48bc5e633/setup.py'"'"'; __file__='"'"'/private/var/folders/ts/yxklk_lj3f32_q1kkljflz5h0000gn/T/pip-install-q3c_oaef/pyheif_88ea55c096834e3e8b4bbae48bc5e633/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/ts/yxklk_lj3f32_q1kkljflz5h0000gn/T/pip-record-phe46c7r/install-record.txt --single-version-externally-managed --compile --install-headers /Users/user/venv/HEICToJPG/include/site/python3.8/pyheif Check the logs for full command output.

我们需要更多地了解您的环境,比如您有什么类型的机器,您是否使用docker,如果是,您使用什么类型的docker映像,等等。

我会给你一个一般的答案,也许你回来后我们可以详细讨论你的问题。

  • 尝试按照repo中描述的命令进行操作https://github.com/carsales/pyheif
brew install libffi libheif

如果您正在使用docker,则将以下包添加到RUN命令中

RUN apt-get install -y libffi-dev libheif-dev libde265-dev

最新更新