【问题标题】:I/O Error: Couldn't open file 'Invoice/a.pdf': No such file or directoryI/O 错误:无法打开文件“发票/a.pdf”:没有这样的文件或目录
【发布时间】:2021-04-08 12:36:22
【问题描述】:

我正在尝试从发票中读取一些数据。

我的test.py:

from invoice2data import extract_data
from invoice2data.extract.loader import read_templates

templates = read_templates('template/a.pdf')
print(templates)

result = extract_data('Invoice/a.pdf', templates=templates)
print(result)

这里我的基本文件夹具有以下结构:

 |template
 |      | a.pdf
 |
 |Invoice
 |      | a.pdf
 |
 |test.py

但它说以下错误:

[]
I/O Error: Couldn't open file 'Invoice/a.pdf': No such file or directory.
False
No template for Invoice/a.pdf
[Finished in 1.399s]

我该如何解决?我必须使用invoice2data 0.3.5

【问题讨论】:

  • 你用绝对路径试过了吗?
  • 您当前的工作目录(请参阅os.getcwd())可能不是您的 test.py 脚本所在的文件夹。这完全取决于您如何运行脚本。

标签: python io


【解决方案1】:

你要么需要把目录放进去。

templates = read_templates('template/a.pdf')

尝试将路径放入该区域。 (r'{PATH}')

或者在编辑器中制作文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-05
    • 2015-02-25
    • 2019-07-27
    • 2013-12-15
    • 2014-03-02
    • 1970-01-01
    相关资源
    最近更新 更多