我遇到了一个错误,使我超出了我的反窃听能力。卡梅洛特对Ghostscript的使用似乎找到了错误架构的可执行文件。
采取的步骤:
brew install Ghostscript
/opt/homebrew/bin
和/opt/homebrew/lib
添加到适当的路径中(我认为?)camelot/camelot/ext/ghostscript/_gsprint.py Line 256
libgs = ctypes.util.find_library("gs")
到libgs = distutils.spawn.find_executable("gs")
/opt/homebrew/bin/gs
python3.9 -m pip install camelot-py
我应该注意到,位置gs
/opt/homebrew/bin/gs
似乎是一个别名,不确定这是否重要,但这是合理的,它将抛出异常。但是,在错误中传递的下两个“查找”,据我所知,/opt/homebrew/bin/gs
和/opt/homebrew/Cellar/ghostscript/9.53.3_1/bin/gs
都是合适的可执行文件。
常识告诉我,如果我使用Windows,我会遇到64位和32位的问题.但是我使用的是MacOS,这是我不熟悉的。
MacOS -苹果硅M1 -Python3.9- brew已安装的Ghostscript - pip安装了camelot-py -试图通过木星笔记本
编辑--还应该注意,Python2.7是MacBook附带的一个基本安装,它建议不要删除它。which python
或python -- version
返回2.7版本,而不是我运行的3.9版本。
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/camelot/ext/ghostscript/_gsprint.py in <module>
259 try:
--> 260 libgs = cdll.LoadLibrary("libgs.so")
261 except OSError:
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py in LoadLibrary(self, name)
451 def LoadLibrary(self, name):
--> 452 return self._dlltype(name)
453
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error, winmode)
373 if handle is None:
--> 374 self._handle = _dlopen(self._name, mode)
375 else:
OSError: dlopen(libgs.so, 6): image not found
During handling of the above exception, another exception occurred:
OSError Traceback (most recent call last)
<ipython-input-4-3a80516ee21f> in <module>
1 file = r"/Users/joe_kiefner/Documents/Projects/Migration Station/Data_Lake/Arkansas/AR_12_10_2020.pdf"
2
----> 3 tables = camelot.read_pdf(file, flavor = 'lattice', pages='5')
4
5 t_df = tables[0].df
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/camelot/io.py in read_pdf(filepath, pages, password, flavor, suppress_stdout, layout_kwargs, **kwargs)
111 p = PDFHandler(filepath, pages=pages, password=password)
112 kwargs = remove_extra(kwargs, flavor=flavor)
--> 113 tables = p.parse(
114 flavor=flavor,
115 suppress_stdout=suppress_stdout,
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/camelot/handlers.py in parse(self, flavor, suppress_stdout, layout_kwargs, **kwargs)
169 parser = Lattice(**kwargs) if flavor == "lattice" else Stream(**kwargs)
170 for p in pages:
--> 171 t = parser.extract_tables(
172 p, suppress_stdout=suppress_stdout, layout_kwargs=layout_kwargs
173 )
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/camelot/parsers/lattice.py in extract_tables(self, filename, suppress_stdout, layout_kwargs)
400 return []
401
--> 402 self._generate_image()
403 self._generate_table_bbox()
404
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/camelot/parsers/lattice.py in _generate_image(self)
209
210 def _generate_image(self):
--> 211 from ..ext.ghostscript import Ghostscript
212
213 self.imagename = "".join([self.rootname, ".png"])
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/camelot/ext/ghostscript/__init__.py in <module>
22 #
23
---> 24 from . import _gsprint as gs
25
26
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/camelot/ext/ghostscript/_gsprint.py in <module>
274 if not libgs:
275 raise RuntimeError("Please make sure that Ghostscript is installed")
--> 276 libgs = cdll.LoadLibrary(libgs)
277
278 del __win32_finddll
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py in LoadLibrary(self, name)
450
451 def LoadLibrary(self, name):
--> 452 return self._dlltype(name)
453
454 __class_getitem__ = classmethod(_types.GenericAlias)
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error, winmode)
372
373 if handle is None:
--> 374 self._handle = _dlopen(self._name, mode)
375 else:
376 self._handle = handle
OSError: dlopen(/opt/homebrew/bin/gs, 6): no suitable image found. Did find:
/opt/homebrew/bin/gs: mach-o, but wrong architecture
/opt/homebrew/Cellar/ghostscript/9.53.3_1/bin/gs: mach-o, but wrong architecture
发布于 2021-10-04 22:55:04
我遇到了一个类似的问题,并设法解决了它。
我的问题是,我使用了x86版本的Python (通过Anaconda)。我通过跑步发现了这一点:
$ file $(which python)
/Users/cscanlin/opt/anaconda3/envs/marvin/bin/python: Mach-O 64-bit executable x86_64
通过安装一个新的通用Python二进制文件进行修正:
$ file /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64]
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3 (for architecture x86_64): Mach-O 64-bit executable x86_64
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3 (for architecture arm64): Mach-O 64-bit executable arm64
不幸的是,目前还没有为Anaconda基地的武器提供官方支持。
https://stackoverflow.com/questions/65819425
复制相似问题