Skip to content
Advertisement

How do I resolve “No module named ‘frontend'” error message?

I have installed PymuPDF/fitz because am trying to extract images from PDF files. However, upon running the code below, I am seeing No module named 'frontend'.

    doc = fitz.open(pdf_path)
            for i in range(len(doc)):
                for img in doc.getPageImageList(i):
                    xref = img[0]
                    pix = fitz.Pixmap(doc, xref)
                    if pix.n < 5:  # this is GRAY or RGB
                        pix.writePNG("p%s-%s.png" % (i, xref))
                    else:  # CMYK: convert to RGB first
                        pix1 = fitz.Pixmap(fitz.csRGB, pix)
                        pix1.writePNG("p%s-%s.png" % (i, xref))
                        pix1 = None
                    pix = None

I have searched but there isn’t single report of this kind of error. I have installed PyMuPDF, muPDF and fitz modules

Here is the error in full:

    Traceback (most recent call last):
      File "/home/waqar/PycharmProjects/predator/ExtractFileImage.py", line 1, in <module>
        import fitz
      File "/home/waqar/anaconda3/envs/retinanet/lib/python3.6/site-packages/fitz/__init__.py", line 1, in <module>
        from frontend import *
    ModuleNotFoundError: No module named 'frontend'

Advertisement

Answer

I’ve solved it by:

pip install PyMuPDF

This will actually allow the import of the fitz you appear to want. (There’s another fitz, which is probably not what you want if you’re manipulating PDF files.)

NOTE: If you get RuntimeError: Directory 'static/' does not exist after install than do:

pip uninstall fitz

for more info see: raise RuntimeError(f”Directory ‘{directory}’ does not exist”) RuntimeError: Directory ‘static/’ does not exist from import fitz

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement