How To Install Pyqt5 For Mac Os

Using PyInstaller with PyQt on Mac OS-X. PyInstaller has only preliminary support for Mac OS-X and currently (Feb. 2010) needs some workarounds and modifications to work properly with PyQt. Therefore this short how-to will show the steps to make the QtWebKit based 'Minibrowser' sample app from here into an OS-X application bundle. I play video games with my kids. Thank you for watching! If you like the video, be sure to click 'Like' so YouTube can share it with others. Subscribe to get our latest videos. Meanwhile I have the ultimate way to install PyQt5 on macOS. Don't use Homebrew. It is great for installing Qt5, but for PyQt5 the best way to install it is using. Python3 -m pip install PyQt5 This works very quickly and uses universal Python Wheels. Simple, just copy PyQt4 source files folder (the folder called something like PyQt-mac-gpl-4.xx.x) to the Desktop and try again. – Gerardo Contijoch Sep 10 '13 at 14:54 add a comment.

PyInstaller has only preliminary support for Mac OS-X and currently (Feb. 2010) needs some workarounds and modifications to work properly with PyQt. Therefore this short how-to will show the steps to make the QtWebKit based 'Minibrowser' sample app from here into an OS-X application bundle.

Prerequisites

  • Recent versions of Qt and PyQt need to be installed.

How To Install Pyqt5 For Mac Os High Sierra

I installed PyQt and Eric4 according to this guide. The following versions were used: OS-X 10.6.2, Python 2.6.1, Qt 4.6.2., PyQt 4.7, sip 4.10, QScintilla 2.4.2. Eric4 is obviously optional for the purpose of this how-to.

Installing and patching PyInstaller

Mac
  • Create a working folder, for example:
    • /Users/username/pywork
    • Open a Terminal window and
  • Download the current pyinstaller source:
    • > Checked out revision 771

  • Modify pyinstaller/source/linux/main.c by commenting out the following 'wait()' section at the end of the file:
    • This deals with the problem 'Icon and Menu is missing from PyQt apps, when running an OS-X App Bundle'. The patch is described and can be downloaded here.

  • Setup pyinstaller:
  • Patch Build.py, otherwise we get a 'Python image not found error'
    • Browse to Ticket #152 'pyinstaller onefile fails to bundle Python framework shared lib on osx'

    • Download pyinstaller.patch and copy it into pywork/pyinstaller

Making the Application into an App Bundle

How To Install Pyqt5 For Mac Os 10.10

  • Download a the Minibrowser sample project:
    • From here into the pywork directory and unzip

  • In the main loop add window.raise_():
    • this deals with the PyQt specific problem in OS-X, that an application window is not automatically brought to the front on launch as expected. link

    • for example in pywork/minibrowser/minibrowser.py modify as follows
  • Change to the pywork directory & make the spec file:

  • Add the following to the bottom of your spec file:
  • Build the Application Bundle:
  • Fix the Bundle:
    • Change the key in pywork/Minibrowser.app/Contents/Info.plist to
  • To deal with the issue 'OS-X App Bundle is missing most files' described here

    • Copy the missing app files into pywork/Minibrowser.app/Contents/MacOS:
  • To prevent the Error: 'qt_menu.nib could not be loaded' described here

    • Into the pywork/Minibrowser.app/Contents/Resources folder copy qt_menu.nib from /Library/Frameworks/QtGui.framework/Versions/4/Resources/qt_menu.nib

Test and Compress the App

  • You should now be able to run the application bundle just like any native OS-X application by double clicking on it.
  • Minibrowser usage: Enter a url and click the Navigate button

  • Package the app in a compressed dmg for distribution, this reduces the size to about one third.

Check the linked issue tickets and PyInstaller tracker and release notes, as these issues will be resolved sometime and the steps with workarounds will hopefully not be needed any more.

Comments are closed.