gpt4 book ai didi

Python-camelot(错误 : GhostscriptNotFound while it is installed)

转载 作者:太空宇宙 更新时间:2023-11-04 04:26:57 29 4
gpt4 key购买 nike

我正在尝试使用 camelot 从 pdf 中提取表格数据,但出现以下错误。

代码:

tables = camelot.read_pdf(file_name)

错误:

GhostscriptNotFound: Please make sure that Ghostscript is installed and available on the PATH environment variable

我已经安装了 Ghostscript,并且在 PATH 环境变量中可用。

请查看以下版本详细信息:

  • Windows-10-10.0.17134-SP0
  • Python 3.6.5 |Anaconda, Inc.| (默认,2018 年 3 月 29 日,13:32:41)[MSC v.1900 64 位 (AMD64)]
  • NumPy 1.14.3
  • openCV 3.4.3
  • 柯莱特 0.3.2

请帮助解决这个问题。

最佳答案

将 Ghostscript 的“bin”和“lib”路径添加到 PATH 对我有用:

  • C:\Program Files\gs\gs9.26\bin
  • C:\Program Files\gs\gs9.26\lib

然后您需要应用该更改,具体取决于具体用例。

按严重程度排序

  • 重启 Python - 这应该可以正常工作
  • 让Python自动获取Gostscript并更新运行环境
  • 如果可以并且作为最后的手段,请重新启动

一般情况下,无需进入运行 Python interpreter 的每个操作系统和每个环境(例如 Jupyter sessionIDECLI ),重启通常是过度的。对于某些人来说,重启是不可能的。

在应用安装程序完成或您自己更改 PATH 后,只需关闭并重新打开您的环境(如上定义)。

没有什么可以阻止您使用 subprocess 更改您的 Python 脚本 中的 PATH用于安装附加应用程序或 os 的模块模块,或通过引用应用程序的绝对路径,例如

# Updating the current PATH inside Python

import os
from pathlib import Path
def update_app_path(app, new_path):
# Get the PATH environment variable
existing = [Path(p) for p in os.environ["PATH"].split(os.path.pathsep))
# Copy it, deleting any paths that refer to the application of interest
new_path = [e for e in existing if not Path(e/app).exists()]
# Append a the new entry
new_path.append(new_path)
# or you could use new_path.append(Path(new_path).parent)
# Reconstruct and apply the PATH
os.environ["PATH"] = os.path.pathsep.join(map(str, new_path))

这是因为 Python 在启动时获取当前环境的副本,之后它使用 os 或 shell 调用执行的任何操作都使用该复制的环境。改变 Python 内的环境不会改变用户在运行 Python 之外的环境,除非有意这样做,否则这种方式的改变不是永久性的。

关于Python-camelot(错误 : GhostscriptNotFound while it is installed),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53319099/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com