Unable to get page count. Is poppler installed and in PATH?
现象
1 |
|
解决
系统中未安装 poppler,这是一个用于呈现可移植文档格式(PDF)文档的免费软件实用程序库。
poppler 官网:https://poppler.freedesktop.org/
Centos
直接用下面的命令进行安装:
1 |
|
如果没有安装“poppler-utils”就会出现如下所示的错误:Exception: Unable to get page count. Is poppler installed and in PATH?
Ubuntu
直接用下面的命令进行安装:
1 |
|
安装完成之后,可以通过输入以下命令检查 Poppler 版本:
1 |
|
输出 pdftotext version 代表成功
1 |
|
windows
poppler-windows 下载地址:https://github.com/oschwartz10612/poppler-windows/releases/
下载压缩包 zip
即可。下载后解压到任意一个文件目录,建议是c盘,如 C:\Program Files
有两种方式使用:
将解压后目录
C:\Program Files\poppler-23.05.0\Library\bin
添加到系统的环境变量中。加完之后需要重启 pycharm。修改源码,修改安装包内的
pdf2image.py
中的poppler
路径1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22def convert_from_path(
pdf_path,
dpi=200,
output_folder=None,
first_page=None,
last_page=None,
fmt="ppm",
jpegopt=None,
thread_count=1,
userpw=None,
use_cropbox=False,
strict=False,
transparent=False,
single_file=False,
output_file=uuid_generator(),
poppler_path=r'C:\Program Files\poppler-23.05.0\Library\bin', #将这里改为你解压安装的poppler路径
grayscale=False,
size=None,
paths_only=False,
use_pdftocairo=False,
timeout=None,
}
Unable to get page count. Is poppler installed and in PATH?
https://flepeng.github.io/021-Python-71-报错-Unable-to-get-page-count-Is-poppler-installed-and-in-PATH?/