如何在 Windows 中将 ghostscript DLL 库提供给 python?

Posted

技术标签:

【中文标题】如何在 Windows 中将 ghostscript DLL 库提供给 python?【英文标题】:How to feed ghostscript DLL library to python in Windows? 【发布时间】:2021-09-05 14:50:34 【问题描述】:

背景。我想使用使用 ghostscript 的camelot.read_pdf(file)

    项目有ghostscript包。 Windows 10 已安装 Ghostscript 9.54.0 for Windows (64 bit)。 2.1。 c:\Program Files\gs\gs9.54.0\bin 已添加到系统 PATH 环境变量中。 Python 3.9 64 位。

所需的库路径是c:\Program Files\gs\gs9.54.0\bin\gsdll64.dll。但是python没有“看到”它。因为它可能没有加载到系统中。

  File "C:\Users\USERNAME\.virtualenvs\PROJECT\lib\site-packages\camelot\backends\ghostscript_backend.py", line 31, in convert
    raise OSError(
OSError: Ghostscript is not installed. You can install it using the instructions here: https://camelot-py.readthedocs.io/en/master/user/install-deps.html

那么,它应该如何工作?我错过了哪一步?

【问题讨论】:

您的PATH environmetn 变量是否正确?它应该包含c:\Program Files\gs\gs9.54.0\bin - 为了在python解释器中找到gsdll64.dll @Petesh,是的,我已将c:\Program Files\gs\gs9.54.0\bin 添加到PATH @Petesh,感谢您的说明,只是仔细检查了它在 Python 中的实际呈现方式。事实并非如此,PyCharm 必须重新启动。现在可以了。 【参考方案1】:

解决了。

首先,Python 可以通过环境 PATH 变量中的路径找到 DLL。因此,路径c:\Program Files\gs\gs9.54.0\bin 必须在那里显示。

必须重新加载 PyCharm(或其他 IDE)(这是我的主要错误)。

感谢@Petesh 的评论。

【讨论】:

以上是关于如何在 Windows 中将 ghostscript DLL 库提供给 python?的主要内容,如果未能解决你的问题,请参考以下文章