我想使用 ocrmypdf 将一些 pdf 文件从图片转换为可读的 pdf -
使用以下简单代码进行了尝试:(invoice.pdf 当然可以在与 python-script 相同的路径中使用,并且应该生成 output.pdf)
import ocrmypdf
if __name__ == '__main__':
fn = r"C:\Users\Polzi\Documents\DEV\Python-Diverses\PDFOCR\invoice.pdf"
ocrmypdf.ocr(fn, 'output.pdf', deskew=True)
但不幸的是,我收到此错误消息:
$ python exPDFOCR.py
[WinError 2] Das System kann die angegebene Datei nicht finden
Traceback (most recent call last):
File "C:\Users\Polzi\Documents\DEV\Python-Diverses\PDFOCR\exPDFOCR.py", line 25, in <module>
ocrmypdf.ocr('invoice.pdf', 'output.pdf', deskew=True)
File "C:\Users\Polzi\Documents\DEV\.venv\testing\lib\site-packages\ocrmypdf\api.py", line 336, in ocr
check_options(options, plugin_manager)
File "C:\Users\Polzi\Documents\DEV\.venv\testing\lib\site-packages\ocrmypdf\_validation.py", line 271, in check_options
ocr_engine_languages = plugin_manager.hook.get_ocr_engine().languages(options)
File "C:\Users\Polzi\Documents\DEV\.venv\testing\lib\site-packages\ocrmypdf\builtin_plugins\tesseract_ocr.py", line 155, in languages
return tesseract.get_languages()
File "C:\Users\Polzi\Documents\DEV\.venv\testing\lib\site-packages\ocrmypdf\_exec\tesseract.py", line 143, in get_languages
proc = run(
File "C:\Users\Polzi\Documents\DEV\.venv\testing\lib\site-packages\ocrmypdf\subprocess\__init__.py", line 53, in run
proc = subprocess_run(args, env=env, **kwargs)
File "c:\users\polzi\appdata\local\programs\python\python39\lib\subprocess.py", line 505, in run
with Popen(*popenargs, **kwargs) as process:
File "c:\users\polzi\appdata\local\programs\python\python39\lib\subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "c:\users\polzi\appdata\local\programs\python\python39\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden
为什么他不能在执行 py 文件的同一文件夹中找到该文件?