Ghostscript无法找到Ghostscript库(libgs)
我在一台运行10.6.8系统的MacBook Pro上,使用Ghostscript时遇到了这个错误信息:
Traceback (most recent call last):
File "/Users/arnoutaertgeerts/Documents/Eclips/SlideTalk 2.0/slidetalk.py", line 13, in <module>
import ghostscript
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ghostscript-0.4.1-py2.7.egg/ghostscript/__init__.py", line 33, in <module>
import _gsprint as gs
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ghostscript-0.4.1-py2.7.egg/ghostscript/_gsprint.py", line 290, in <module>
raise RuntimeError('Can not find Ghostscript library (libgs)')
RuntimeError: Can not find Ghostscript library (libgs)
我用以下命令安装了这个软件包:
pip install ghostscript
4 个回答
0
你是怎么想要“使用”Ghostscript的呢?看起来这是一个来自Python的错误,它找不到libgs(我对Python不太了解)。
我不确定libgs是否包含在Mac的安装中,但如果有的话,libgs应该在Ghostscript的文件夹里。你检查过它是否存在吗?
如果存在,那么最可能的问题是它不在搜索路径中,不过我对Mac是怎么处理搜索的就不太清楚了。
0
ctypes.find_library这个函数会在/urs/local/lib这个文件夹里查找库文件。
我把这个路径加到了我的ghostscript模块里:
/opt/local/lib/libgs
1
对于新用户,特别是使用M1 Mac的朋友,ghostscript可能会出现缺少libgs文件的错误,而这个文件在usr/local/lib
目录下找不到。
解决这个问题可以按照以下步骤进行,记得顺序要对:
- 首先运行
brew install ghostscript
来安装ghostscript。 - 接着运行
conda install ghostscript
,这个命令会从conda-forge安装适合arm_64架构的库。 - 如果conda出现频道错误,可以尝试使用
conda install -c conda-forge ghostscript
。 - 最后,运行
pip install ghostscript
来安装ghostscript。
注意:
- libgs.dylib文件可以在通过homebrew安装的ghostscript中找到。
- 修改
_gsprint.py
中的地址会出错,因为通过brew安装的版本是arm_64架构,而通过pip安装的版本是OS_X86架构。 - Python不会识别通过conda安装的ghostscript模块,除非先运行pip安装,所以这一步是必不可少的。