MacOS – In Sierra: How to get Qt 5.8.0 / PyQt 5.7.1 / sip 4.19 / Python3.5 to install & work correctly

macospython

I am experiencing trouble trying to get the combination of Qt 5.8.0 / PyQt 5.7.1 / sip 4.19 / Python3.5 to install & work correctly on my macOS 10.12.2 (Sierra).

Steps to reproduce the problem:

(I am being very specific for if anyone else will ever venture here trying to accomplish the same thing)

  1. Install Python3.5 via homebrew (brew install python3.5).
  2. Installing PyQt5 via homebrew however did not work as my python code complained that it could not find the pyqt module. I fixed it by applying some symlinks. Yet, the code remained buggy throwing up errors like QtGui.QApplication was missing etc. I also found multiple complains of macOS users that had run into similar problems but I could not find any real solution. So, I removed all my symlinks and ran brew uninstall pyqt5.
  3. Then I found this gist on GitHub, and started following that so I:
  4. Downloaded qt-opensource-mac-x64-clang-5.8.0.dmg from qt-project.org
  5. Downloaded SIP and PyQt5-gpl sources as mentioned in the gist.
  6. I then unpacked the SIP & PyQt5 tar files. Then I executed the command:

    python3.5 ~/Downloads/sip-4.19/configure.py -d /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages --arch x86_64
    
  7. So far, so good. Also make, sudo make install & sudo make clean, as mentioned in the gist, executed without a problem.

  8. Now, I arrived at step nr. 13 from the gist, which told me to make a small change to the !host_build command listed in the ~/Qt5.8.0/5.8/clang_64/mkspecs/qdevice.pri file. The file however did not mention any !host_build comment at all, so I added one myself.
  9. Then, at step 15 from the gist I executed:

    python3.5 configure.py --destdir /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages --qmake ~/Qt5.8.0/5.8/clang_64/bin/qmake
    
  10. This gave a SDK path error, which I fixed by running sudo xcode-select -s /Applications/Xcode.app/Contents/Developer as per instruction on this post on Stack from people that ran into a similar problem.

  11. Now, the code mentioned above in step 10 did execute, but it threw up an error:

    Error: This version of PyQt5 and the commercial version of Qt have incompatible licenses

  12. So, I searched and arrived at a post on the QT forum. It helped me solve the error by making some small adjustments to PyQt5's configure.py file (commenting out the license check).

  13. Then, I was finally able to successfully run the command I mentioned at step 10 (step 15 from the gist).
  14. However, when I tried to run make again, everything seems to be going perfect until it now throws out this error that, so far, I have not been able to fix:

    ~/Downloads/PyQt5_gpl-5.7.1/QtCore/sipQtCoreQt.cpp:1093:62: error: no member named 'WindowCancelButtonHint' in namespace 'Qt'; did you mean
          'WindowCloseButtonHint'?
        {sipName_WindowCancelButtonHint, static_cast<int>( ::Qt::WindowCancelButtonHint), 419},
                                                           ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
    
    
        WindowCloseButtonHint
    ../../../Qt5.8.0/5.8/clang_64/lib/QtCore.framework/Headers/qnamespace.h:300:9: note: 'WindowCloseButtonHint' declared here
            WindowCloseButtonHint = 0x08000000,
            ^
    ~/Downloads/PyQt5_gpl-5.7.1/QtCore/sipQtCoreQt.cpp:1106:58: error: no member named 'WindowOkButtonHint' in namespace 'Qt'
        {sipName_WindowOkButtonHint, static_cast<int>( ::Qt::WindowOkButtonHint), 419},
                                                       ~~~~~~^
    2 errors generated.
    make[1]: *** [sipQtCoreQt.o] Error 1
    make: *** [sub-QtCore-make_first-ordered] Error 2
    

Is there anyone able to help me out?

Best Answer

I am the one who did the Qt5 5.8.0 upgrade for Homebrew. This is a known problem that will persist until Riverbank upgrades their software. I suggest you contact them on their mailing list.

UPDATE: As a temporary workaround, I've added a qt@5.7 formula, and updated the PyQt5 formula to depend on it. See the following pull requests, which I've merged:

https://github.com/Homebrew/homebrew-core/pull/9297

https://github.com/Homebrew/homebrew-core/pull/9308