ImportError: cannot import name '_wxcolors' from partially initialized module 'pymupdf' (most likely due to a circular import)
What happened?
Running Dangerzone 0.9.0-rc1 on Windows, built using our install/windows/setup-windows.py script, fails with the following error:
This error is reminiscent of a cx_Freeze bug that we have encountered before (#981).
operating system version
Microsoft Windows 10
Dangerzone version
0.9.0-rc1 (unreleased)
Docker info
Document conversion logs
Additional info
Error:
ImportError: cannot import name '_wxcolors' from partially initialized module 'pymupdf' (most likely due to a circular import)
The following workaround seems to work:
diff --git a/setup-windows.py b/setup-windows.py
index ac5331a3..7252b587 100644
--- a/setup-windows.py
+++ b/setup-windows.py
@@ -13,7 +13,7 @@ setup(
description="Dangerzone",
options={
"build_exe": {
- "packages": ["dangerzone", "dangerzone.gui"],
+ "packages": ["dangerzone", "dangerzone.gui", "pymupdf._wxcolors"],
"excludes": ["test", "tkinter"],
"include_files": [("share", "share"), ("LICENSE", "LICENSE")],
"include_msvcr": True,
Oh, I was about to open an issue to the cx_freeze issue tracker, but I just found out that another user has already done so, and there's a fix out there: https://github.com/marcelotduarte/cx_Freeze/issues/2848
Hm, turns out that switching to cx_Freeze 8.1.0 (which contains this fix) does not work, because we encounter a different error (see https://github.com/marcelotduarte/cx_Freeze/issues/2878). Until upstream has a fix for that, we have to use the above workaround. I propose we keep this issue open until we can package Dangerzone with the latest cx_Freeze version and no workarounds.
There's a new cx_Freeze release out, let's check if our issue is resolved.
I just checked, and I can verify that the packaging error is fixed, but now we're dealing with a runtime error that I've reported upstream: https://github.com/marcelotduarte/cx_Freeze/issues/2938
... and I tested with an old cx_Freeze version, hence the bug. I have verified that with cx_Freeze 8.2.0, everything works.