ModuleNotFoundError: No module named 'frontend'

天大地大妈咪最大 提交于 2020-05-15 04:14:07

问题


I have installed PymuPDF/fitz but upon running the sample code below, I am trying to extract images from PDF files

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

it gives me following error, i have searched but there isn't single report of this kind of error, i have installed PyMuPDF, muPDF and fitz modules

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'

回答1:


I've solved it by:

pip install PyMuPDF



回答2:


In file /home/waqar/anaconda3/envs/retinanet/lib/python3.6/site-packages/fitz/__init__.py

change

from frontend to from fitz.frontend



来源:https://stackoverflow.com/questions/56467667/modulenotfounderror-no-module-named-frontend

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!