Install Pyqt4 Mac

This is a simple guide on installing the latest Qt (currently 5.6) and PyQt5 on Mac OS X 10.11 (El Capitan) and Linux with Python 3.4, inside a virtual environment.

Brew install pyqt Warning: pyqt 5.14.0 is already installed and up-to-date To reinstall 5.14.0, run `brew reinstall pyqt` As I failed to install pyqt4 with fink, I tried it with python, which I failed again. I downloaded SIP and PyQt4, and installed SIP with python. Then when I tried to install PyQt4, I received message below.

Installation Steps

'PyQt is a set of Python v2 and v3 bindings for The Qt Company's Qt application framework and runs on all platforms supported by Qt including Windows, MacOS/X and Linux. PyQt5 supports Qt v5. PyQt4 supports Qt v4 and will build against Qt v5. The bindings are implemented as a set of Python modules and contain over 1,000 classes.' Jan 27, 2011 How to install PyQt4. Download and install ActivePython. Open Command Prompt. Type pypm install pyqt4. Read the notes specific to this package. Windows (32-bit). The easiest way to combine Qt Designer and Python is via the PyQt binding. To install PyQt, simply enter the following on the command line: python3 -m venv venv source venv/bin/activate # or 'call venv Scripts activate.bat' on Windows python3 -m pip install PyQt5 (This assumes you have Python 3 installed.).

  • Python 3
  • Xcode and command-line tools
  • Qt libraries
  • Virtual environment
  • SIP Python package
  • PyQt5 Python package

Python 3

First of all, make sure that Python 3 is available on your system. You can easily check this by opening the terminal and entering the command python3. If you need to install it, check out the Python homepage, or install it with homebrew (brew install python3) on OS X or your favorite Linux package manager.

Mac

Install Xcode and command-line tools

If you are using OS X, download Xcode and install it. Then install the command-line tools by entering the following command in the terminal: xcode-select --install. This adds a number of tools to your system, such as make, git, gcc, c++ and g++.

Install Qt Libraries

First we need to download and install the Qt libraries:

I’d recommend to install Qt into the directory /opt/qt. The installation requires about 14 GB of disk space, and includes a number of apps and utilities:

  • Qt Creator.app - a complete IDE with a graphical GUI designer and code editor (more)
  • 5.6/clang_64/bin/Designer.app - the GUI designer
  • 5.6/clang_64/bin/pixeltool.app - a tool to inspect the pixels around the mouse cursor
  • 5.6/clang_64/bin/qmlscene - execute scenes from .QML files
  • 5.6/clang_64/bin/qtdiag - Prints diagnostic output about the Qt library
  • Various others such as qmllint, qmlmin, qmlplugindump, qmlprofiler, qmlscene, qmltestrunner

Furthermore the Qt installation includes a number of examples in the Examples subdirectory.

Create a virtualenv for the PyQt5 and SIP libs

For this guide, we create a virtual environment with Python 3.4 under the home directory in ~/.venv/qtproject:

At this point, typing the command which python3 should output something like ~/.venv/qtproject/bin/python3.

Install SIP

PyQt requires to have the SIP module installed. SIP is a tool for automatically generating Python bindings for C and C++ libraries.

You can either download the .tar.gz file, or install the latest from the source repository with mercurial (hg):

Install PyQt5

Install

Finally we get to install the PyQt5 module.

Start by downloading the tar.gz file, in this case PyQt-gpl-5.5.1.tar.gz, and extracting it:

All Done!

At this point, everything is successfully installed! Now let’s check if everything works by importing PyQt5 from Python 3.4:

And just for the sake of it, let’s build a simple hello world Qt application:

Save this program as helloqt.py and execute it with python3 helloqt.py (or, if the virtualenv is not activated, with ~/.venv/qtproject/bin/python3 helloqt.py), and be greeted with this:

🎉 Congratulations 🎉

Now have fun with some GUI programming! Here are a few useful next steps:

Install Pyqt4 Mac Download

If you have suggestions or feedback, let me know via @metachris

Mac

Update 2016-03-25: python3 -m venv instead of virtualenv

Install

Last Update Aug/13/2012: check out PyQtX, nice and easy one stop installation app. Thanks AbiusX!

I’ve been searching for the ways to successfully install PyQt4 on my Macbook Pro with Lion 10.7.2.

Pyqt4

After a long hard test, here comes my final working steps:

1) Download All the Required Software

  • Qt 4.7.4 Library: http://get.qt.nokia.com/qt/source/qt-mac-opensource-4.7.4.dmg

  • SIP 4.13: http://www.riverbankcomputing.co.uk/static/Downloads/sip4/sip-4.13.tar.gz

  • PyQt 4.6.8: http://www.riverbankcomputing.co.uk/static/Downloads/PyQt4/PyQt-mac-gpl-4.8.6.tar.gz

2) Install Qt 4.7

This is pretty straightforward. Double click it and install it like a normal dmg file. It will be installed under /Developer/Applications/Qt

3) Install SIP

  • Unzip SIP 4.13, then from terminal, cd into the folder:
  • Then type:

After that, it will install to your current version of python. ( in my mac, I only have 2.7)

Install Pyqt4 Mac Free

If you want to specify which python to use, you can type:

  • Make and install it:

4) Change some code in Qt

Since Qt 4.7 does not officially support Lion, you might get error like: “This version of Mac OS X is unsupported”, if you are not going to use some of its features in Lion, Qt will work pretty well. In order to get rigid of this annoying error, you need to make some changes to the header file named: qglobal.h, which lies in /Library/Frameworks/QtCore.framework/Versions/4/Headers

  • Open qglobal.h by using any editor, like vim.

  • Find the following line:

  • And add the following line of code

Install Pyqt4 Mac App

  • Then find this line
  • And change it to

Install Pyqt4 Mac Mojave

Save and close the file.

5) Install PyQt

  • Unzip PyQt into a folder, and cd into that folder, like what we just did for install SIP
  • Inside PyQt’s folder, type
  • After that, type
  • It takes about 10 mins to finish, then type

If everything goes well, you should find a folder named PyQt4 under /Library/Python/2.7/site-packages/

To test if you have successfully installed it, go to python prompt and type

Install Pyqt4 Mac Version

and then see if it can be loaded without errors.

Good Luck!