M1 Mac使用Camelot报错:Ghostscript arm64架构不兼容
M1 Mac上Camelot读取PDF时Ghostscript架构不兼容问题
在M1 Mac(arm64架构)上使用Python的camelot库读取PDF文件时,出现Ghostscript架构不兼容报错,提示已安装的Ghostscript为x86_64架构,不符合arm64需求。
执行代码及报错堆栈
>>> import camelot >>> import pandas >>> data = camelot.read_pdf('path/to/pdf.pdf') Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/camelot/ext/ghostscript/_gsprint.py", line 260, in <module> libgs = cdll.LoadLibrary("libgs.so") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ctypes/__init__.py", line 460, in LoadLibrary return self._dlltype(name) ^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ctypes/__init__.py", line 379, in __init__ self._handle = _dlopen(self._name, mode) ^^^^^^^^^^^^^^^^^^^^^^^^^ OSError: dlopen(libgs.so, 0x0006): tried: 'libgs.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibgs.so' (no such file), '/usr/lib/libgs.so' (no such file, not in dyld cache), 'libgs.so' (no such file), '/usr/lib/libgs.so' (no such file, not in dyld cache) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/camelot/io.py", line 113, in read_pdf tables = p.parse( ^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/camelot/handlers.py", line 173, in parse t = parser.extract_tables( ^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/camelot/parsers/lattice.py", line 402, in extract_tables self._generate_image() File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/camelot/parsers/lattice.py", line 211, in _generate_image from ..ext.ghostscript import Ghostscript File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/camelot/ext/ghostscript/__init__.py", line 24, in <module> from . import _gsprint as gs File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/camelot/ext/ghostscript/_gsprint.py", line 268, in <module> libgs = cdll.LoadLibrary(libgs) ^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ctypes/__init__.py", line 460, in LoadLibrary return self._dlltype(name) ^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ctypes/__init__.py", line 379, in __init__ self._handle = _dlopen(self._name, mode) ^^^^^^^^^^^^^^^^^^^^^^^^^ OSError: dlopen(/Users/adrumm/lib/libgs.dylib, 0x0006): tried: '/Users/adrumm/lib/libgs.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/adrumm/lib/libgs.dylib' (no such file), '/Users/adrumm/lib/libgs.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/usr/local/Cellar/ghostscript/10.02.1/lib/libgs.10.02.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/Cellar/ghostscript/10.02.1/lib/libgs.10.02.dylib' (no such file), '/usr/local/Cellar/ghostscript/10.02.1/lib/libgs.10.02.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))
已尝试的操作
- 执行
brew install ghostscript安装Ghostscript - 确认Ghostscript符合camelot官方文档安装要求
- 测试过使用/不使用虚拟环境,问题均存在
疑问
已安装arm64版本Python,此前Stack Overflow上同类问题的回复无法解决当前问题,请问该问题是否可以修复?
内容的提问来源于stack exchange,提问作者Abigail
相关产品推荐
相关产品推荐

