python - 文本摘要 : failed with exit code 127//windows 10//pdftotext

标签 python pyinstaller file-not-found pypdf pdftotext

当我尝试运行我的(在使用 pyinstaller 部署之后)程序以读取和转换 PDF 文件并将其输入到 google 表格中时。我收到下图中显示的错误。但是我似乎无法弄清楚问题是什么:

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 -------------

enter image description here

最佳答案

您似乎遇到了 FileNotFoundError。如果您查看错误,正在运行的命令是:

pdftotext //Mac/Home/Desktop/Wickey Einkauf Test/Rekeningen/Lekkerkerker_ - 
 0803471.pdf -

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

pdftotext "example file path.pdf" -

关于python - 文本摘要 : failed with exit code 127//windows 10//pdftotext,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63357517/

相关文章:

Python Selenium 网络驱动程序 : Debugging

python - 如何使用旧版本的 glibc,让 Python 脚本在 RHEL 3 上运行,在 CentOS 6 上使用 PyInstaller

python - Errno 185090050 _ssl.c :343: error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib, 被PyInstaller打包成exe后

java - "java.io.FileNotFoundException"与作为函数参数的端口号 8080 相关的错误

python - 如何使用带参数的任务计划程序运行 python 脚本

python - 无法以某种自定义方式排列和打印网页中的某些字段

python - 同时选择和重命名列

python - Dask + pyinstaller 失败

python - ImportError : The 'enchant' C library was not found. 请通过您的操作系统包管理器安装它,或使用 PyPI 的预构建二进制轮

ios - 未找到外部框架文件/File.h (Parse/Parse.h) 文件