python ghostscript:RuntimeError:找不到Ghostscript库(libgs)

问题描述 投票:2回答:3

当试图运行hello-world示例时

import sys
import ghostscript

args = [
    "ps2pdf", # actual value doesn't matter
    "-dNOPAUSE", "-dBATCH", "-dSAFER",
    "-sDEVICE=pdfwrite",
    "-sOutputFile=" + sys.argv[1],
    "-c", ".setpdfwrite",
    "-f",  sys.argv[2]
    ]

ghostscript.Ghostscript(*args)

得到错误:

 File "/Users/ddd/sss/ddd/eee.py", line 2, in <module>
    import ghostscript
  File "build/bdist.macosx-10.6-universal/egg/ghostscript/__init__.py", line 33, in <module>

  File "build/bdist.macosx-10.6-universal/egg/ghostscript/_gsprint.py", line 290, in <module>
RuntimeError: Can not find Ghostscript library (libgs)

什么是这个libgs库,我该如何获得它?

顺便说一下,我在Mac上

python macos ghostscript
3个回答
1
投票

你应该看看Ghostscript's official download site以及their documentation

如果这不能让你开始,你也可以直接在他们的IRC服务器irc.freenode.net上名为#ghostscript的在线聊天频道中询问GS开发人员。他们是一群非常友善和乐于助人的人。


1
投票

要解决此问题,您需要修改site-packages中的ghostscript模块路径。

在_gsprint.py中修改成这样的东西:

libgs = ctypes.util.find_library('/opt/local/lib/libgs')

它找到你的libgs文件。


1
投票

对我来说,只是我安装了python部分:

pip install ghostscript

但不是C部分:

brew install ghostscript

也许这些DMG也有效 - 但我没有走这条路:http://pages.uoregon.edu/koch/

© www.soinside.com 2019 - 2024. All rights reserved.