我正在使用模块 pdf2drive 将我的 pdf 文件转换为图像。但是当我运行时,弹出一条错误消息:“无法获取页数。是否已安装 poppler 并在 PATH 中?”
我安装了 poppler,并添加了环境变量的路径。在命令提示符下,它可以正常运行。 命令提示符中的消息
但之后,在 IDE 中报告了相同的错误消息。 IDE 中的错误消息
我应该怎么做才能解决这个问题?谢谢!
这是我的代码:
import cv2
import pytesseract
from PIL import Image
import sys
from pdf2image import convert_from_path
import os
pdf_file = 'historical_data.pdf'
pages = convert_from_path(pdf_file,600)
image_path = 'pdf_image/'
image_counter = 1
for page in pages:
filename = "page_"+str(image_counter)+".png"
page.save(image_path+filename,600)
image_counter +=1