【やりたいこと】
Python上でPDFを画像に変換したいです。
最終的な目的は、同じくPython上で、tesseractによるOCRを行うこと。
【試したこと・その他】
popplerをDL、解凍し、Cドライブに格納
「環境変数の設定」にてPathを通した
「C:\python\test1.pdf」というPDFファイルを使用したい
【参考にしたサイト】
https://shotanuki.com/python%E3%81%A7pdf%E3%82%92%E7%94%BB%E5%83%8F%E3%81%AB%E5%A4%89%E6%8F%9B%E3%81%99%E3%82%8B/
https://teratail.com/questions/164621
など
【実行コード】
from
1 2images = convert_from_path('test1.pdf') 3images[0].save('test.png', 'png')
【返ってきたエラー】
Traceback
1 File "C:\Users\hiramatsua41\AppData\Local\Programs\Python\Python37\lib\site-packages\pdf2image\pdf2image.py", line 224, in _page_count 2 proc = Popen(command, env=env, stdout=PIPE, stderr=PIPE) 3 File "C:\Users\hiramatsua41\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 775, in __init__ 4 restore_signals, start_new_session) 5 File "C:\Users\hiramatsua41\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 1178, in _execute_child 6 startupinfo) 7FileNotFoundError: [WinError 2] 指定されたファイルが見つかりません。 8 9During handling of the above exception, another exception occurred: 10 11Traceback (most recent call last): 12 File "C:\python\16c_OCR.py", line 3, in <module> 13 images = convert_from_path('test1.pdf') 14 File "C:\Users\hiramatsua41\AppData\Local\Programs\Python\Python37\lib\site-packages\pdf2image\pdf2image.py", line 53, in convert_from_path 15 page_count = _page_count(pdf_path, userpw, poppler_path=poppler_path) 16 File "C:\Users\hiramatsua41\AppData\Local\Programs\Python\Python37\lib\site-packages\pdf2image\pdf2image.py", line 228, in _page_count 17 raise PDFInfoNotInstalledError('Unable to get page count. Is poppler installed and in PATH?') 18pdf2image.exceptions.PDFInfoNotInstalledError: Unable to get page count. Is poppler installed and in PATH?
以上となります。
どなたか、何か分かる方・・・ご助力を頂けますようよろしくお願いします!m(_ _)m
回答1件
あなたの回答
tips
プレビュー