我在 Windows 上编写了一个脚本,以使用现有 pdf 中的 ocr 创建一个 pdf。
我的代码:
import ocrmypdf
if __name__ == '__main__':
ocrmypdf.ocr('C:\\Users\\User\\workplace\\proofofconceptPdf\\scan.pdf', 'C:\\Users\\User\\workplace\\proofofconceptPdf\\output.pdf')
那是我的简单脚本,输出是:
[WinError 2] The system cannot find the specified file
[WinError 2] The system cannot find the specified file
Traceback (most recent call last):
File "c:\Users\User\workplace\proofofconceptPdf\main.py", line 9, in <module>
pdf('scan.pdf', 'text.pdf')
File "c:\Users\User\workplace\proofofconceptPdf\main.py", line 6, in pdf
ocrmypdf.ocr(file_path, save_path, force_ocr=True)
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\ocrmypdf\api.py", line 336, in ocr
check_options(options, plugin_manager)
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\ocrmypdf\_validation.py", line 271, in check_options
ocr_engine_languages = plugin_manager.hook.get_ocr_engine().languages(options)
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\ocrmypdf\builtin_plugins\tesseract_ocr.py", line 155, in languages
return tesseract.get_languages()
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\ocrmypdf\_exec\tesseract.py", line 143, in get_languages
proc = run(
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\ocrmypdf\subprocess\__init__.py", line 53, in run
proc = subprocess_run(args, env=env, **kwargs)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 505, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the specified file
谁能帮我?