首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >T提取:失败,退出代码为127 // windows 10 // pdftotext

T提取:失败,退出代码为127 // windows 10 // pdftotext
EN

Stack Overflow用户
提问于 2020-08-11 19:49:26
回答 2查看 3.2K关注 0票数 3

当我尝试运行我的(在使用pyinstaller部署之后)程序来读取和转换PDF文件并将其输入到google工作表中时。我得到了下图所示的错误。然而,我似乎找不出问题是什么:

代码语言:javascript
运行
复制
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\trpfinance\AppData\Local\Programs\Python\Python38-32\lib\site-packages\textract\parsers\utils.py", line 82, in run
    pipe = subprocess.Popen(
  File "C:\Users\trpfinance\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\trpfinance\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\trpfinance\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__
    return self.func(*args)
  File "EinkaufRGWindows.py", line 40, in InkoopRekeningen
    text = textract.process(str(importfolder) + str(i))
  File "C:\Users\trpfinance\AppData\Local\Programs\Python\Python38-32\lib\site-packages\textract\parsers\__init__.py", line 77, in process
    return parser.process(filename, encoding, **kwargs)
  File "C:\Users\trpfinance\AppData\Local\Programs\Python\Python38-32\lib\site-packages\textract\parsers\utils.py", line 46, in process
    byte_string = self.extract(filename, **kwargs)
  File "C:\Users\trpfinance\AppData\Local\Programs\Python\Python38-32\lib\site-packages\textract\parsers\pdf_parser.py", line 28, in extract
    raise ex
  File "C:\Users\trpfinance\AppData\Local\Programs\Python\Python38-32\lib\site-packages\textract\parsers\pdf_parser.py", line 20, in extract
    return self.extract_pdftotext(filename, **kwargs)
  File "C:\Users\trpfinance\AppData\Local\Programs\Python\Python38-32\lib\site-packages\textract\parsers\pdf_parser.py", line 43, in extract_pdftotext
    stdout, _ = self.run(args)
  File "C:\Users\trpfinance\AppData\Local\Programs\Python\Python38-32\lib\site-packages\textract\parsers\utils.py", line 90, in run
    raise exceptions.ShellError(
textract.exceptions.ShellError: The command `pdftotext //Mac/Home/Desktop/Wickey Einkauf Test/Rekeningen/Lekkerkerker_ - 20803471.pdf -` failed with exit code 127
------------- stdout -------------
------------- stderr -------------

EN

回答 2

Stack Overflow用户

发布于 2020-08-11 23:06:28

看起来你得到了一台FileNotFoundError。如果您查看该错误,则运行的命令是:

代码语言:javascript
运行
复制
pdftotext //Mac/Home/Desktop/Wickey Einkauf Test/Rekeningen/Lekkerkerker_ - 
 0803471.pdf -

这里有几个我会看的东西。首先,在文件路径的开头有一个额外的斜杠,这似乎是错误的。其次,文件路径中有空格,但路径中没有引号。这第二部分意味着pdftotext将把它作为几个单独的命令参数读取,而不是一个。您可以通过格式化您的子流程调用来修复此问题,使文件用引号括起来,如下所示:

代码语言:javascript
运行
复制
pdftotext "example file path.pdf" -
票数 1
EN

Stack Overflow用户

发布于 2020-12-04 06:22:05

您需要使用pip安装pdftotext。要安装它,您需要安装Microsoft Visual C++ 14或更高版本。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63357517

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档