From 2c3c50a09bf0cadd16256a952e6fed91f12a81f9 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Wed, 22 Nov 2023 12:33:38 +0000 Subject: [PATCH] mac build: fix pyinstaller erroring due to not being able to import pyqt6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not sure why this a problem in the mac build but not in the windows build... Also not sure why this only came up now -- was working before. (I changed a few things in prev commits re the build scripts but I can't see the cause) ``` 34827 INFO: Processing module hooks... 34828 INFO: Loading module hook 'hook-cryptography.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks'... 35932 INFO: Loading module hook 'hook-mnemonic.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks'... 35937 INFO: Loading module hook 'hook-certifi.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks'... 35939 INFO: Loading module hook 'hook-dns.rdata.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks'... 36502 INFO: Loading module hook 'hook-usb1.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/usb1/__pyinstaller'... 36503 INFO: --- libusb1 pyinstaller hook --- 36504 INFO: Added libusb binaries: [] 36505 INFO: Loading module hook 'hook-sqlite3.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 36932 INFO: Loading module hook 'hook-pkg_resources.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 38303 INFO: Loading module hook 'hook-PyQt5.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 38584 WARNING: Hidden import "sip" not found! 38586 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 38587 INFO: Loading module hook 'hook-lib2to3.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 38678 INFO: Loading module hook 'hook-_tkinter.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 39005 INFO: checking Tree 39006 INFO: Building Tree because Tree-00.toc is non existent 39006 INFO: Building Tree Tree-00.toc 39021 INFO: checking Tree 39022 INFO: Building Tree because Tree-01.toc is non existent 39022 INFO: Building Tree Tree-01.toc 39157 INFO: checking Tree 39158 INFO: Building Tree because Tree-02.toc is non existent 39158 INFO: Building Tree Tree-02.toc 39165 INFO: Loading module hook 'hook-encodings.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 39568 INFO: Loading module hook 'hook-distutils.util.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 39586 INFO: Loading module hook 'hook-platform.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 39587 INFO: Loading module hook 'hook-PyQt5.QtGui.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 39734 INFO: Loading module hook 'hook-PyQt5.QtPrintSupport.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 39984 INFO: Loading module hook 'hook-PyQt5.QtMultimedia.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 40164 INFO: Loading module hook 'hook-packaging.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 40165 INFO: Loading module hook 'hook-pickle.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 40187 INFO: Loading module hook 'hook-heapq.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 40192 INFO: Loading module hook 'hook-difflib.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 40196 INFO: Loading module hook 'hook-PyQt5.QtWidgets.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 40361 INFO: Loading module hook 'hook-multiprocessing.util.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 40382 INFO: Loading module hook 'hook-sysconfig.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 40421 INFO: Loading module hook 'hook-PyQt5.QtNetwork.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 40545 INFO: Loading module hook 'hook-xml.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 40691 INFO: Loading module hook 'hook-distutils.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 40692 INFO: Loading module hook 'hook-PyQt5.QtCore.py' from '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks'... 40903 INFO: Looking for ctypes DLLs 40987 WARNING: Library Cfgmgr32 required via ctypes not found 40992 WARNING: Library setupapi required via ctypes not found 40994 WARNING: Library Advapi32 required via ctypes not found 40996 WARNING: Ignoring /System/Library/Frameworks/IOKit.framework/IOKit imported from /Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/serial/tools/list_ports_osx.py - only basenames are supported with ctypes imports! 40996 WARNING: Ignoring /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation imported from /Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/serial/tools/list_ports_osx.py - only basenames are supported with ctypes imports! 41028 INFO: Analyzing run-time hooks ... 41041 INFO: Including run-time hook '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pyqt5.py' 41043 INFO: Including run-time hook '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pkgutil.py' 41047 INFO: Including run-time hook '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks/rthooks/pyi_rth_inspect.py' 41049 INFO: Including run-time hook '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks/rthooks/pyi_rth_subprocess.py' 41051 INFO: Including run-time hook '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks/rthooks/pyi_rth_multiprocessing.py' 41055 INFO: Including run-time hook '/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pkgres.py' 41140 INFO: Looking for dynamic libraries 719 INFO: gettext setting initial language to None Traceback (most recent call last): File "/Users/vagrant/electrum/contrib/osx/build-venv/bin/pyinstaller", line 8, in sys.exit(run()) File "/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/__main__.py", line 178, in run run_build(pyi_config, spec_file, **vars(args)) File "/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/__main__.py", line 59, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/building/build_main.py", line 934, in main build(specfile, distpath, workpath, clean_build) File "/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/building/build_main.py", line 856, in build exec(code, spec_namespace) File "contrib/osx/osx.spec", line 48, in a = Analysis([electrum+ MAIN_SCRIPT, File "/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/building/build_main.py", line 381, in __init__ self.__postinit__() File "/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/building/datastruct.py", line 173, in __postinit__ self.assemble() File "/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/building/build_main.py", line 660, in assemble isolated.call(find_binary_dependencies, list(self.binaries), self.binding_redirects, collected_packages) File "/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/isolated/_parent.py", line 238, in call return isolated.call(function, *args, **kwargs) File "/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/isolated/_parent.py", line 176, in call raise RuntimeError(f"Child process call to {function.__name__}() failed with:\n" + output) RuntimeError: Child process call to find_binary_dependencies() failed with: File "/Users/vagrant/electrum/electrum/gui/qml/__init__.py", line 8, in import PyQt6 ModuleNotFoundError: No module named 'PyQt6' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/isolated/_child.py", line 63, in run_next_command output = function(*args, **kwargs) File "/Users/vagrant/electrum/contrib/osx/build-venv/lib/python3.10/site-packages/PyInstaller/building/build_main.py", line 157, in find_binary_dependencies __import__(package) File "/Users/vagrant/electrum/electrum/gui/qml/__init__.py", line 10, in sys.exit("Error: Could not import PyQt6. On Linux systems, you may try 'sudo apt-get install python3-pyqt6'") SystemExit: Error: Could not import PyQt6. On Linux systems, you may try 'sudo apt-get install python3-pyqt6' 🗯 ERROR: Could not build binary ``` --- electrum/gui/qml/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/electrum/gui/qml/__init__.py b/electrum/gui/qml/__init__.py index 35926cb70..7e28f61f5 100644 --- a/electrum/gui/qml/__init__.py +++ b/electrum/gui/qml/__init__.py @@ -6,13 +6,19 @@ from typing import TYPE_CHECKING try: import PyQt6 -except Exception: - sys.exit("Error: Could not import PyQt6. On Linux systems, you may try 'sudo apt-get install python3-pyqt6'") +except Exception as e: + from electrum import GuiImportError + raise GuiImportError( + "Error: Could not import PyQt6. On Linux systems, " + "you may try 'sudo apt-get install python3-pyqt6'") from e try: import PyQt6.QtQml -except Exception: - sys.exit("Error: Could not import PyQt6.QtQml. On Linux systems, you may try 'sudo apt-get install python3-pyqt6.qtquick'") +except Exception as e: + from electrum import GuiImportError + raise GuiImportError( + "Error: Could not import PyQt6.QtQml. On Linux systems, " + "you may try 'sudo apt-get install python3-pyqt6.qtquick'") from e from PyQt6.QtCore import (Qt, QCoreApplication, QLocale, QTranslator, QTimer, QT_VERSION_STR, PYQT_VERSION_STR) from PyQt6.QtGui import QGuiApplication