I’ve never posted here before, but this time I’m genuinely stuck. I’m using cx_Freeze on a python script that uses pdf2docx. Running the python script normally works fine, but running cx_Freeze’s executable gives this error:
Unhandled exception: <class ‘ModuleNotFoundError’>, No module named ‘mupdf’
Traceback (most recent call last):
File “C:UserstrumaAppDataLocalProgramsPythonPython312Libsite-packagespymupdf_init_.py”, line 193, in
from . import mupdf
ImportError: cannot import name ‘mupdf’ from partially initialized module ‘pymupdf’ (most likely due to a circular import) (C:UserstrumaDocumentsballotreadercloneballotreaderresourcesbuildexe.win-amd64-3.12libpymupdf_init_.pyc)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “ballots.py”, line 1149, in startInitUI
File “C:UserstrumaAppDataLocalProgramsPythonPython312Libasynciobase_events.py”, line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File “ballots.py”, line 1155, in initUI
File “ballots.py”, line 23, in runOtherInit
File “C:UserstrumaAppDataLocalProgramsPythonPython312Libsite-packagespdf2docx_init_.py”, line 1, in
from .converter import Converter
File “C:UserstrumaAppDataLocalProgramsPythonPython312Libsite-packagespdf2docxconverter.py”, line 9, in
import fitz
File “C:UserstrumaAppDataLocalProgramsPythonPython312Libsite-packagesfitz_init_.py”, line 2, in
from pymupdf import *
File “C:UserstrumaAppDataLocalProgramsPythonPython312Libsite-packagespymupdf_init_.py”, line 197, in
import mupdf
ModuleNotFoundError: No module named ‘mupdf’
I’ve tried every suggestion chatgpt had, but nothing worked.
From my analysis it seems like cx_Freeze is messing up the order of imports in all the different python files, and ends up tying itself in a knot that it can’t get out of… or something.
Yes, I’ve tried installing mupdf. It doesn’t look like mupdf is supported for python 3 anymore though.
I’ve also tried reinstalling pdf2docx, pymupdf, and pip.
Ploso is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.