How To Install Pyqt5 For Mac Os

To install PyQt on Mac OS X, you must already have the Xcode tools installed. This is because a compiler and build tool are required to install PyQt. Xcode is a very large package, normally supplied on a separate developer's CD provided with the machine; it is also available online from http://developer.apple. com/tools/xcode. The following instructions assume that Xcode is already installed.

  1. Install Pyqt5 On Linux
  2. How To Install Pyqt5 For Mac Os 64-bit

No obvious regressions with pyqt version upgrade. MacOS BigSur fix for pyqt5 not responding. I couldn't find the exact bug to link to qt's patch notes. How to install PyQt5 on Mac OS X? On Apple Mac OS X installation is a bit simpler. The first step to take is to install the Mac OS X binary. This installs the PyQt GUI library. But to use it from Python, you also need Python module. This is where the tool brew comes. # install pyqt5 brew install pyqt5-with-python # install qscintilla2 with qt5 support brew install qscintilla2-with-plugin-with-python PyQt4 Installation with QScintilla DEPRECATED ¶ On Mac OS ¶.

Although Macs are normally supplied with a version of Python preinstalled, it may be an old version, in which case we recommend installing an up-to-date version for PyQt development. To check the Python version, start up a Terminal, and type in python -V; if this prints 'Python 2.5', or a higher version number, there is no need to install a new version of Python.

The files required for installing PyQt are qt-mac-opensource-4.2.3.dmg, python-2.5.1-macosx.dmg (unless you already have Python 2.5 or later installed), sip-4.6.tar.gz, and, PyQt-mac-gpl-4.2.tar.gz. The book's examples are in the file pyqtbook.tar.gz.

Start by getting Qt. Go to http://www.trolltech.com/developer/downloads/qt/ index and click the Qt/Mac Open Source Edition link, and near the bottom of the page, download qt-mac-opensource-4.2.3.dmg. A later version number, say, 4.3.1, should also be fine.

If you need to install an up-to-date version of Python, go to http://www.python. org/download and download the Python 2.5.1 for Macintosh OS X version—for example, python-2.5.1-macosx.dmg. A later 2x series version, such as 2.5.2 or

2.6.0, should also be okay, providing they are production releases (not alphas, betas, or release candidates).

Trainz 2 download free. The last two tools that must be obtained are SIP and PyQt. Go to http://www. riverbankcomputing.co.uk/sip/download.php and download the source package sip-4.6.tar.gz, then go to, http://www.riverbankcomputing.co.uk/pyqt/download .php and download the source package PyQt-mac-gpl-4.2.tar.gz. Again, the version numbers may be higher—for example, 4.3—for PyQt.

If you want to run the examples that are shown in the book or to see the model answers to the exercises, you can unpack the pyqtbook.tar.gz file available from http://www.qtrac.eu/pyqtbook.html.

Now that all the pieces are at hand, and assuming that Xcode is already installed, you can perform the PyQt installation. Both Qt and Python must be installed first, then SIP, and finally PyQt itself. We will assume that the versions are those mentioned earlier, but obviously, use whichever versions you downloaded and adjust accordingly. We assume that all the downloaded files are on the Desktop, and that you know the administration password (which is normally your own password).

Figure A.4 Installing Qt on Mac OS X

First set up Qt by double-clicking qt-mac-opensource-4.2.3.dmg, or whichever Qt package you downloaded, and following the instructions. The installer's first screen is shown in Figure A.4. We assume that you accept all the defaults and install in the standard locations. Older Qt versions have an unoptimized build tool, and this means that the setup can take a surprisingly long time. More up-to-date versions have an optimized build tool which works much faster.

Figure A.5 Installing Python on Mac OS X
How to install pyqt5 designer

Install Pyqt5 On Linux

Once Qt is installed, it is time to install Python, if you need to. Doubleclick python-2.5.1-macosx.dmg or the package you downloaded. The installer's first screen is shown in Figure A.5. This may pop up a new window with a MacPython.mpkg file—just double-click this to start up the installer, and follow the instructions. Just as for Qt, we assume that you accept the defaults and install in the standard locations. If you already have one or more older Python versions you will find that these remain intact, with two new Python executables added to /usr/local/bin along with their names, including the version numbers—for example, python2.5 and pythonw2.5. The first executable is used in Terminal windows, and the second is used for running GUI applications and avoids a Terminal from being needlessly popped up in the background.

The installation should make the Python version just installed the default version. To check, close any existing Terminal windows, and then start up a fresh Terminal window, and type python -V. If the version is not the one installed, the settings will need to be changed manually. Close the Terminal, and then in Finder, go to Applications^MacPython 2.5, and start up the Python Launcher. Open the Preferences dialog (shown in Figure A.6), and for each item in the Settings for file type combobox—for Python Scripts, Python GUI Scripts, and Python Bytecode Documents—change the version of Python. For the Python Scripts and Python Bytecode Documents entries, change to /usr/local/bin/python2.5, and for the Python GUI Scripts entry, change to /usr/local/bin/pythonw2.5 (note the 'w' in the executable's name). These values may not be available in the drop-down lists, in which case they must be typed in manually. For each entry, also be sure to uncheck the Run in a Terminal window checkbox.

Both SIP and PyQt must be built in a Terminal. Close all open Terminals, and then start a fresh one. Type python -V to make sure that the correct Python is be-

Figure A.6 Setting which Python to use on Mac OS X

ing used. If it is not, see the preceding paragraph; alternatively, enter the full name of the version of Python you want to use—for example, python2.5 con-figure.py.

How To Install Pyqt5 For Mac Os 64-bit

SIP must be built first, by typing the following into the Terminal:

How to install pyqt5 mac os

cd $HOME/Desktop tar xvfz sip-4.6.tar.gz cd sip-4.6

python configure.py make sudo make install

You will be asked for the administration password (normally your own password) when you execute the sudo command at the end. Now, PyQt can be installed.

cd $HOME/Desktop tar xvfz PyQt-mac-gpl-4.2.tar.gz cd PyQt-mac-gpl-4.2 python configure.py make sudo make install

Again, you will be prompted for a password when you execute the sudo command. Building PyQt can take quite a long time, so you will need to be patient.

The Qt documentation is available through Qt Assistant, which can be run from Finder. PyQt's documentation is supplied in HTML format in the $HOME/Desktop/PyQt-mac-gpl-4.2/doc directory. It is worthwhile moving this somewhere permanent and adding a suitable bookmark to your browser. It also comes with numerous examples; at the very least it is worth looking at the PyQt examples and running the demo. (For example, change the directory to $HOME/Desktop/PyQt-mac-gpl-4.2/examples/tools/qtdemo and run ,/qtdemo.py.)

If you downloaded the book's examples, you might like to unpack pyqtbook. tar.gz in $HOME to get a $HOME/pyqt directory with all the book's examples, and model answers to the exercises, categorized by chapter. In the $HOME/pyqt directory itself you will find mkpyqt.py and makepyqt.pyw; you might like to move (or soft-link) these to a directory on your $PATH—for example, $HOME/bin—to make them more convenient to use. Some of the examples depend on Qt Designer .ui files or on .qrc resource files. How to turn these into Python modules is covered on page 207, but for now it might be convenient to simply perform the conversions:

This will convert any .ui and .qrc files that are found in the pyqt directory and in its subdirectories.* If you prefer to use the GUI makepyqt.pyw tool, you may have to click its More—Tool paths option and set the path to pyuic4. It may also be necessary to set the paths to the other tools too.

This completes the installation for Mac OS X. If you unpacked the examples, you could go to the Desktop and click the pyqt directory, then the chap12 directory, and then click multipedes.pyw to see a graphics application. If an unwanted Terminal window pops up, right-click multipedes.pyw, and click the Info dialog; change the Open with setting to the Python Launcher for the correct version of Python, and apply the change to all files with the .pyw suffix.

You are now ready to write and run PyQt applications on your Mac OS X machine—and they will run unchanged on Windows and Linux too!

Was this article helpful?