How can I install PyQt5 on Mac?

后端 未结 6 887
醉酒成梦
醉酒成梦 2021-02-07 09:31

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
         


        
6条回答
  •  礼貌的吻别
    2021-02-07 09:46

    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

提交回复
热议问题