How can I install PyQt5 on Mac?

后端 未结 6 902
醉酒成梦
醉酒成梦 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:39

    Qt is set of cross-platform C++ libraries that implement high-level APIs for accessing many aspects of modern desktop and mobile systems. These include location and positioning services, multimedia, NFC and Bluetooth connectivity, a Chromium based web browser, as well as traditional UI development.

    PyQt5 is a comprehensive set of Python bindings for Qt v5. It is implemented as more than 35 extension modules and enables Python to be used as an alternative application development language to C++ on all supported platforms including iOS and Android.

    PyQt5 may also be embedded in C++ based applications to allow users of those applications to configure or enhance the functionality of those applications.

         brew install PyQt5 (or) pip3 install PyQt5
    
    0 讨论(0)
  • 2021-02-07 09:40

    I'm kind of dodging the question, but the simplest way is to install Homebrew, and just run brew install pyqt or brew install pyqt5.

    0 讨论(0)
  • 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

    0 讨论(0)
  • 2021-02-07 09:56

    Qt has a Mac .dmg installer with all the components. I uninstalled my pip version first, and installed my Qt into the standard location - I tried putting into /opt/Qt as suggested by another post, but it failed due to changes to MacOS rights in Mojave. There is an expansion triangle next to the Qt item which allows for installing Designer separately from the Qt engine and the 2D/3D development and platform-specific tools.

    Qt Installer:

    https://www.qt.io/download-qt-installer

    0 讨论(0)
  • 2021-02-07 10:01

    In ~/.pip/pip.log I discovered:

    Skipping https://pypi.python.org/packages/... (from https://pypi.python.org/simple/pyqt5/) because it is not compatible with this Python
    

    Simply installed newwer version of Python 3 from official website and pip3 install PyQt5 finally worked.

    0 讨论(0)
  • 2021-02-07 10:03

    You need to install SIP first, which is not just running configure.py:

    >>> cd ~/Downloads/sip-4.17
    >>> python configure.py
    >>> make
    >>> make install
    

    Then you can install PyQt5:

    >>> cd ~/Downloads/PyQt-gpl-5.5.1
    >>> python configure.py --qmake /Users/name/Qt/5.5/clang_64/bin/qmake
    >>> make
    >>> make install
    
    0 讨论(0)
提交回复
热议问题