pip3 install PyMuPDF
Collecting PyMuPDF Using cached PyMuPDF-1.18.17-cp37-cp37m-win_amd64.whl (5.4 MB)
Installing collected packages: PyMuPDF
Successfully installed PyMuPDF-1.18.17
import fitz
doc = fitz.open("my_pdf.pdf")
When I look for def open on the fitz.py file, I find nothing.
So I understand the error But I don't understand why the file that I download doesn't have this function ? Can someone share the good files please ? Or maybe I missed something else ?
FULL TRACE:
runfile('D:/Documents/Python_projects/Point_and_area_pdf_to_excel/get_info.py', wdir='D:/Documents/Python_projects/Point_and_area_pdf_to_excel')
Reloaded modules: six, dateutil._common, dateutil.relativedelta, dateutil.tz._common, dateutil.tz._factories, dateutil.tz.win, dateutil.tz.tz, dateutil.tz, dateutil.parser._parser, dateutil.parser.isoparser, dateutil.parser, chardet.enums, chardet.charsetprober, chardet.charsetgroupprober, chardet.codingstatemachine, chardet.escsm, chardet.escprober, chardet.latin1prober, chardet.mbcssm, chardet.utf8prober, chardet.mbcharsetprober, chardet.euctwfreq, chardet.euckrfreq, chardet.gb2312freq, chardet.big5freq, chardet.jisfreq, chardet.chardistribution, chardet.jpcntx, chardet.sjisprober, chardet.eucjpprober, chardet.gb2312prober, chardet.euckrprober, chardet.cp949prober, chardet.big5prober, chardet.euctwprober, chardet.mbcsgroupprober, chardet.hebrewprober, chardet.sbcharsetprober, chardet.langbulgarianmodel, chardet.langgreekmodel, chardet.langhebrewmodel, chardet.langrussianmodel, chardet.langthaimodel, chardet.langturkishmodel, chardet.sbcsgroupprober, chardet.universaldetector, chardet.version, chardet
Traceback (most recent call last):
File "D:\Documents\Python_projects\Point_and_area_pdf_to_excel\get_info.py", line 45, in <module>
print(get_dict_list(path))
File "D:\Documents\Python_projects\Point_and_area_pdf_to_excel\get_info.py", line 7, in get_dict_list
text_list = get_pdf_page_text_list(pdf_path)
File "D:\Documents\Python_projects\Point_and_area_pdf_to_excel\get_info.py", line 19, in get_pdf_page_text_list
doc = fitz.open(pdf_path)
AttributeError: module 'fitz' has no attribute 'open'
Uninstall and reinstall pyMuPDF.
this error usually indicates that init.py wasn't executed. Which e.g. happens when you are in the installation fitz directory and start python.
> pip uninstall PyMuPDF
Found existing installation: PyMuPDF 1.18.17
Uninstalling PyMuPDF-1.18.17:
Would remove:
/home/deerawj/.local/lib/python3.9/site-packages/PyMuPDF-1.18.17.dist-info/*
/home/deerawj/.local/lib/python3.9/site-packages/fitz/*
Proceed (y/n)? y
Successfully uninstalled PyMuPDF-1.18.17
> pip install PyMuPDF
Collecting PyMuPDF
Downloading PyMuPDF-1.18.17-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (6.4 MB)
|████████████████████████████████| 6.4 MB 62 kB/s
Installing collected packages: PyMuPDF
Successfully installed PyMuPDF-1.18.17
Also check out, https://github.com/pymupdf/PyMuPDF/issues/660
I also ran into the same issue. Had to remove the Fitz, which was a different package than the one PyMuPdf calls. Then even after uninstalling the Fitz and installing pymupdf the same error was coming. This is what worked for me.
pip uninstall fitz
pip install --upgrade --force-reinstall pymupdf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With