首页 > 解决方案 > 如何在 Windows 中将 ghostscript DLL 库提供给 python?

问题描述

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

  1. 该项目有ghostscript包。
  2. Windows 10 安装了Ghostscript 9.54.0 for Windows (64 bit)。2.1。c:\Program Files\gs\gs9.54.0\bin已添加到系统环境PATH变量中。
  3. 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

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

标签: pythonwindowsghostscriptpython-3.9

解决方案


解决了。

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

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

感谢@Petesh 的评论。


推荐阅读