在 Windows 8 上用 Python 导入 Ghostscript

Jas*_*ich 5 python ghostscript

我一直在尝试将 ghostscript 导入 Python,以便将 pdf 文件转换为 .tiff 格式。

我在 Windows 8 上使用 Python 版本 2.7.10。

我已经使用 pip 成功下载并安装了 ghostscript,它出现在正确的位置 (...\Anaconda\Lib\sitepackages)。我已经确认可以将位于此目录中的其他包导入 Python。

我正在使用命令 import ghostscript

当我这样做时,我收到一条错误消息:

运行时错误:在注册表中找不到 Ghostscript DLL

回溯表明调用文件“ghoscript_init_.py”成功将_gsprint导入为gs。

但是,当导入函数尝试访问“ghostscript_gsprint.py”时,它会产生无法找到 Ghostscript DLL 的运行时错误。

我将不胜感激任何建议或提示。谢谢!

小智 5

Jamie的回答不是很有帮助,OP说他确实已经下载并安装了ghostscript,甚至发布说他使用的是python 2.7,应该由ghostscript支持没问题。

我得到了同样的错误: RuntimeError: Can not find Ghostscript DLL in registry

我的问题实际上是我安装了 Python(3.6) 64 位,同时安装了 Ghostscript 32 位。卸载 32 位 Ghostscript 并安装 64 位 Ghostscript 解决了该问题。

您可以通过运行 python.exe 并检查标头消息来检查您的 python 版本。

Python

Python 3.6.6 |Anaconda 公司| (默认,2018 年 6 月 28 日,11:27:44)[MSC v.1900 64 位(AMD64)] 在 win32 上键入“help”、“copyright”、“credits”或“license”以获取更多信息。


Jam*_*ull 3

除了使用ghostscriptPyPI 安装 python 绑定之外pip install ghostscript,您还需要为您的平台安装正确的 Ghostscript 程序,如PyPI 页面上所述。该页面指出需要 8.x 版本,但我目前正在成功使用 9.2。

下载链接在这里