Home > database >  PyMuPDF: AttributeError: 'Document' object has no attribute 'loadPage'
PyMuPDF: AttributeError: 'Document' object has no attribute 'loadPage'

Time:07-03

I'm trying to convert pdf pages in images in order to use OCR on image.

I have Ubuntu 21.10

Python 3

import fitz
# read pdf file
pdf = fitz.open(file_path_name)
# load pdf page using index
page = pdf.loadPage(0)

The pdf is coming from scanner.

I tried to uninstall PyMuPDF, uninstall fitz and reinstall it again but still the error

sudo pip uninstall PyMuPDF
sudo pip uninstall fitz
sudo apt autoremove
sudo apt autoclean
reboot
sudo pip install PyMuPDF

answer

Collecting PyMuPDF
  Using cached PyMuPDF-1.20.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.9 MB)
Installing collected packages: PyMuPDF
Successfully installed PyMuPDF-1.20.0

Any idea?

CodePudding user response:

import fitz
# read pdf file
pdf = fitz.open(file_path_name)
# load pdf page using index
page = pdf.load_page(0)

Try this code it may work it worked for me.I was having a similar problem.

  • Related