Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install PyQt5 on Mac?

I am trying to install PyQt5 on my Mac but I do not know how to use it well. I have tried to install sip doing

cd ~/Downloads/sip-4.17
python configure.py

which worked, and then I tried

cd ~/Downloads/PyQt-gpl-5.5.1
python configure.py --qmake /Users/name/Qt/5.5/clang_64/bin/qmake

which returns an error that says

Make sure you have a working sip on your PATH or use the --sip argument to explicitly specify a working sip.

How do I fix this error? Did I not install sip?

like image 539
user2888499 Avatar asked Jan 04 '16 02:01

user2888499


People also ask

Does PyQt5 work on Mac?

The PyQt module can be used to create desktop applications with Python. In this article you'll learn how to install the PyQt module. Desktop applications made with PyQt are cross platform, they will work on Microsoft Windows, Apple Mac OS X and Linux computers (including Raspberry Pi).

Can I use Qt Designer on Mac?

Install Qt Designer on Windows or Mac.

How do I open a Qt Designer on a Mac?

Open the project. In Qt Creator, choose "File" → "Open File or Project..." or press Ctrl+O (or Command+O on Mac). Navigate to the SampleProject folder and open the file SampleProject.pro. Qt Creator will ask you a few questions about how to set up the build process for this project.


1 Answers

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:

Collecting PyQt5
  Downloading PyQt5-5.9-5.9.1-cp35.cp36.cp37-abi3-macosx_10_6_intel.whl 
(82.2MB)
    100% |████████████████████████████████| 82.2MB 17kB/s 
Collecting sip<4.20,>=4.19.3 (from PyQt5)
  Downloading sip-4.19.3-cp36-cp36m-macosx_10_6_intel.whl (49kB)
    100% |████████████████████████████████| 51kB 1.2MB/s 
Installing collected packages: sip, PyQt5
Successfully installed PyQt5-5.9 sip-4.19.3

You see: Such a wheel is re-used for CPython 3.5, 3.6 and 3.7.

Old remark, but see below: PySide2 is not as far, but we will build similar wheels when we have the first version ready.

Added on 2017/09/25: You can of course also use

pip3 install PyQt5

But at that time my pip/pip2/pip3 was a bit messy linked, so the first solution is rock solid and avoids confusion.

Also right is that you don't always get the lastest version of PyQt5 this way. But for getting started, the priority is to get results quickly and not the bleeding edge.

Update: PySide2 now officially has wheels, to:

$ python3 -m pip install PySide2
Collecting pyside2
  Downloading https://files.pythonhosted.org/packages/2a/e2/2dc134a5c475f661d5ff2ab587fbd2c285db3d064e03ac9b4a2ee0958400/PySide2-5.12.2-5.12.2-cp35.cp36.cp37-abi3-macosx_10_12_intel.whl (109.8MB)
    100% |████████████████████████████████| 109.8MB 238kB/s 
Collecting shiboken2==5.12.2 (from pyside2)
  Downloading https://files.pythonhosted.org/packages/bd/8b/a2ad76c3a935fae51f0ed9b150a9df08167c4550fcd07637f0db19c31849/shiboken2-5.12.2-5.12.2-cp35.cp36.cp37-abi3-macosx_10_12_intel.whl (691kB)
    100% |████████████████████████████████| 696kB 1.6MB/s 
Installing collected packages: shiboken2, pyside2
Successfully installed pyside2-5.12.2 shiboken2-5.12.2

If you see bugs or differences between the two, please feel free to open a bug report. Follow the instructions on https://wiki.qt.io/Qt_for_Python/Reporting_Bugs

like image 58
Christian Tismer Avatar answered Oct 02 '22 23:10

Christian Tismer