0

我在 macbookpro 10.6.8 上,尝试使用 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

4 回答 4

0

您如何尝试“使用” Ghostscript ?这似乎是 Python 的一个错误,它找不到 libgs(恐怕我不会说 Python)

我不确定 libgs 是否包含在 Mac 安装中,但如果包含,那么 libgs 应该位于 Ghostscript 文件夹中。你有没有检查它是否存在?

如果是,那么最可能的问题是它不在搜索路径中,但我不知道如何在 Mac 上解决搜索。

于 2013-03-24T10:37:48.537 回答
0

ctypes.find_library 在 /urs/local/lib 中搜索。

我将此路径添加到我的 ghostscript 模块:

/opt/local/lib/libgs
于 2013-03-24T12:05:40.000 回答
0

我在文件“_gsprint.py”中更改了libgs的路径,它可以工作了~

而不是 libgs.so (libgs = cdll.LoadLibrary("libgs.so"),我使用 libgs = cdll.LoadLibrary("Corresponding_Path_in_my_laptop/libgs.dylib")。

ps:我的Mac上没有libgs.so,只有一个libgs.dylib文件。

感谢@KenS 和@arnoutaertgeerts!

于 2019-07-27T09:56:16.640 回答
0

对于使用 M1 mac 的新用户,ghostscript 可能会显示缺少 libgs 文件错误,并且该文件将在usr/local/lib

可以按照相同的顺序执行以下步骤来解决此问题:

  • brew install ghostscript
  • conda install ghostscript,它从 conda-forge 安装基于 arm_64 的库
  • 如果 conda 抛出通道错误,请尝试使用conda install -c conda-forge ghostscript
  • pip install ghostscript

笔记:

  1. libgs.dylib 文件可以在 ghostscript 的 home brew 安装中找到
  2. 更改地址_gsprint.py会引发错误,因为 brew 安装的版本将基于 arm_64 而 pip 安装的版本将基于 OS_X86
  3. 除非运行 pip install,否则 Python 无法识别 conda install 中的 ghostscript 模块,因此这是必不可少的步骤
于 2021-12-03T11:29:27.680 回答