【问题标题】:Ghostscript Can not find Ghostscript library (libgs)Ghostscript 找不到 Ghostscript 库 (libgs)
【发布时间】:2013-03-23 21:11:09
【问题描述】:

我在 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

【问题讨论】:

    标签: python ghostscript


    【解决方案1】:

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

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

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

    【讨论】:

    • 是的,我在这里找到了它:/opt/local/lib/libgs.dylib
    • 那是在 Mac 搜索路径中吗?我怀疑不是,也许尝试放入 /usr/local/bin (我对 MacOS 知之甚少,所以这可能是错误的)
    【解决方案2】:

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

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

    /opt/local/lib/libgs
    

    【讨论】:

      【解决方案3】:

      我在“_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!

      【讨论】:

        【解决方案4】:

        对于使用 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 模块,因此这是必不可少的步骤

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-10-20
          • 1970-01-01
          • 2017-11-19
          相关资源
          最近更新 更多