Python ocrmypdf:将扫描的文本pdf文件转换为文本

Python ocrmypdf:将扫描的文本pdf文件转换为文本,python,Python,我想使用ocr将扫描的pdf文件转换为文本 我尝试了以下代码: !ocrmypdf F4.pdf output.pdf 但我得到了这个错误: FileNotFoundError: [Errno 2] No such file or directory: 'output.pdf' and the type of variable text:NoneType 如果您有任何建议,我们将不胜感激您的PDF文件不在脚本的工作目录中。您需要指定文件的实际绝对路径,或者指定相对于脚本工作目录的路径。如果不

我想使用ocr将扫描的pdf文件转换为文本 我尝试了以下代码:

!ocrmypdf F4.pdf output.pdf
但我得到了这个错误:

FileNotFoundError: [Errno 2] No such file or directory: 'output.pdf'
and the type of variable text:NoneType

如果您有任何建议,我们将不胜感激

您的PDF文件不在脚本的工作目录中。您需要指定文件的实际绝对路径,或者指定相对于脚本工作目录的路径。如果不确定工作目录是什么,可以使用
os.getcwd()
获取该目录,但它应该与脚本位于同一文件夹中。
FileNotFoundError: [Errno 2] No such file or directory: 'output.pdf'
and the type of variable text:NoneType