I am trying to bundle a PyQt project using Pyinstaller. I tried creating package using command pyinstaller --onedir Hello.py
.
This creates dist folder and h
This is a problem a lot of people were struggling with (including myself). See for example this bug report.
Suggestion 1 (recommended): upgrade to pyinstaller v3.4. According to this pull request, several issues have been solved, in particular the one the OP is referring to. There is generally better support for PyQt5 now.
Suggestion 2: this one worked for me, but is not recommended. It may help for older versions of PyQt5 or if you are not able to upgrade to pyinstaller 3.4: Locate the site-packages directory of your python distribution and apply the following two changes to the PyInstaller module:
Edit 1: PyInstaller/loader/rthooks.dat
- 'PyQt5': ['pyi_rth_qt5.py'],
+ 'PyQt5': ['pyi_rth_qt5.py', 'pyi_rth_qt5plugins.py'],
Edit 2: PyInstaller/utils/hooks/qt.py
- elif namespace == 'PyQt5':
- plugin_dir = os.path.join('PyQt5', 'Qt', 'plugins')
Source: see pull request #2991 by user shadchin.
(I further recommend to use python 3.x. I struggled to bundle PyQt5 successfully for python 2.7.x, but I do not remember if the problems occurred on windows or macOS.)