やってみる

アウトプットすべく己を導くためのブログ。その試行錯誤すらたれ流す。

Raspbian stretch に PyQt5 をインストールする7(PyQt5をインストールする)

 やっと本題。

前回まで

手順

 pip でPyQt5 をインストールする。

A. pip(失敗)

 PyQt5のパッケージを検索する。

(Qt) $ pip search pyqt5
PyQt5-sip (4.19.13)               - Python extension module support for
                                    PyQt5
pyqt5-tools (5.11.2.1.3)          - Tools to supplement the official PyQt5
                                    wheels
python-pyqt5-hexview (0.4.3)      - PyQt5 hex viewer widget.
PyQt5 (5.11.3)                    - Python bindings for the Qt cross
                                    platform UI and application toolkit
python-pyqt5-vstructui (0.4.0)    - PyQt5 vstruct hex viewer widget.
PyQt5-stubs (5.11.3.0)            - 
python-qt5 (0.3.0)                - PyQt5
pyqtspinner (0.1.1)               - A waiting spinner for PyQt5
pyqt5plus (0.1.180513.2115)       - Additional features to PyQt5
pySlipQt (0.5.1)                  - A slipmap widget for PyQt5
qtilities (0.6)                   - Utilities for PyQt5 development
pywiz (0.0.13)                    - A PyQt5 wizard package
altendpyqt5 (0.0.3)               - Extras for working with PyQt5.
pyssb (0.1.1)                     - PyQT5 Site Specific Browser
AnyQt (0.0.10)                    - PyQt4/PyQt5 compatibility layer.
Sonance-Music-Player (0.1.Alpha)  - This is a music player using PyQt5
qutepart (3.2.0)                  - Code editor component for PyQt5
pyqt-led (0.0.6)                  - Simple LED widget for PyQt5
pytc-gui (1.2.2)                  - PyQt5 GUI for pytc API
qt-ledwidget (0.2)                - PyQt5 widget with animated LEDs
yxspkg_songzgif (1.4.2)           - A GUI to make gif based on pyqt5
vext.pyqt5 (0.7.0)                - Use system pyqt5 from a virtualenv
persephonep (1.3.1)               - Web Browser developed by Python and
                                    PyQt5
PyQt5Singleton (0.1)              - A simple singleton implementation to
                                    work with PyQt5
QCandyUi (0.12)                   - quick beautify your pyQt5 app
pyblish-qml (1.8.7)               - Frontend for Pyblish written in
                                    PyQt5/QML
cheesemaker (0.3.8)               - A minimalistic image viewer using
                                    Python3 and PyQt5
quartz-browser (2.2.8)            - Fast Lightweight web browser written in
                                    PyQt5
pyqode.qt (2.10.0)                - Shim library that wraps PyQt5, PyQt4 and
                                    PySide
fgmk (0.7.4)                      - A PyQt5 Maker to generate a RPG
                                    Javascript game.
hackedit (1.0a2)                  - The hackable IDE, built with Python3,
                                    PyQt5 and pyQode
logReader (0.7.6)                 - PyQt5 programm for parse and reading any
                                    log file.
pynoder (1.0.3)                   - A Python and PyQt5 package for creating
                                    a node-based editor.
qutebrowser (1.5.2)               - A keyboard-driven, vim-like browser
                                    based on PyQt5.
PyQtX (0.1.2)                     - Mimics the structure of PyQt5 but
                                    provides PyQt4 as a fallback solution.
python-qdatamatrix (0.1.18)       - A PyQt4/PyQt5 widget for viewing and
                                    editing a DataMatrix object
world2d (0.2.0)                   - A widget for PyQt5 implementing a 2d
                                    world space to draw in.
QtStuff (0.4)                     - Compatibility layer and helper classes
                                    for PySide/PyQt4/PyQt5
qt_backport (0.1.3)               - Makes PySide/PyQt4 code work with Qt5
                                    (using PyQt5)
Qt5.py (0.1.0)                    - Python 2 & 3 compatibility wrapper
                                    around PyQt5 and PySide2
tws-async (0.5.7)                 - Use the Interactive Brokers API (IBAPI)
                                    asynchonouslywith asyncio or PyQt5
qroundprogressbar (1.0.0)         - PyQt5 port of C++ circular progress bar
                                    widget library
TURP1210 (1.2.0)                  - A PyQt5 GUI framework for heavy vehicle
                                    diagnostic adapters using RP1210
txt2mobi3-app (0.2.1)             - A PyQt5 application for converting
                                    Chinese novel txt files into Kindle mobi
                                    files.
pyqt5ac (1.0.3)                   - Python module to automatically compile
                                    UI and RC files in PyQt5 to Python files
tv_viewer (1.1.3)                 - Python PyQt5 GUI to view tv program
                                    details using tvmaze API and SQLite
install-qt-binding (0.0.8)        - Automatic install a qt binding
                                    (pyside/pyside2/pyqt/pyqt5) that could
                                    install in the runtime environment
Qt.py (1.1.0)                     - Python 2 & 3 compatibility wrapper
                                    around all Qt bindings - PySide,
                                    PySide2, PyQt4 and PyQt5.
specguiutils (0.7.1)              - Library to provide PyQt5 widgets to
                                    display spec file information read using
                                    spec2nexus.spec file library
QtPy (1.5.2)                      - Provides an abstraction layer on top of
                                    the various Qt bindings (PyQt5, PyQt4
                                    and PySide) and additional custom
                                    QWidgets.
xcirculardichro (0.9.4)           - Library to provide PyQt5 widgets to
                                    display spec file information read using
                                    spec2nexus.spec file library
PyQt5Designer (5.10.1)            - Python bindings for the Qt cross
                                    platform UI designer,must set windows
                                    PATH Environment like this:     PATH=D:\
                                    soft\Python35\Scripts\;D:\soft\Python35\
                                    ;D:\soft\Python35\Lib\site-
                                    packages\PyQt5;....
QtPyConvert (3.1.0)               - An automatic Python Qt binding
                                    transpiler to the Qt.py abstraction
                                    layer. It aims to help in your
                                    modernization of your Python Qt code.
                                    QtPyConvert supports the following
                                    bindings out of the box: PyQt4, PySide,
                                    PyQt5, PySide2. It also has experimental
                                    support for defining your own bindings.

 PyQt5があったのでインストールするも失敗。

$ pip install PyQt5
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting PyQt5
  Could not find a version that satisfies the requirement PyQt5 (from versions: )
No matching distribution found for PyQt5

B. ソースコードからコンパイル

 SIP Downloadからソースコードを入手する。(今回のバージョンはsip-PyQt5_gpl-5.11.3.tar.gzだった) 解凍する。

(Qt) $ cd /home/pi/root/lib/PyQt5_gpl-5.11.3
(Qt) $ python configure.py
(Qt) $ make
(Qt) $ sudo make install

python configure.py

(Qt) $ python configure.py
Querying qmake about your Qt installation...
Error: PyQt5 requires Qt v5.0 or later. You seem to be using v4.8.7. Use the
--qmake flag to specify the correct version of qmake.

 Qtのバージョンが4.8.7だと怒られた。そんなバカな。過去ログを見ても5のはず。

sudo apt install qt-sdk qtbase5-dev libgl1-mesa-dev

 ググってみるとqt5-defaultをインストールすればいいみたい。

sudo apt install qt5-default
...
この操作後に追加で 139 kB のディスク容量が消費されます。
...

 再び実行すると進んだ。

$ python configure.py
Querying qmake about your Qt installation...
Determining the details of your Qt installation...
This is the GPL version of PyQt 5.11.3 (licensed under the GNU General Public
License) for Python 3.7.1 on linux.

Type 'L' to view the license.
Type 'yes' to accept the terms of the license.
Type 'no' to decline the terms of the license.

Do you accept the terms of the license? 

 yesを入力してENTERキー押下。

Found the license file pyqt-gpl.sip.
Checking to see if the QtGui module should be built...
Disabled QtGui feature: PyQt_Desktop_OpenGL
Checking to see if the QtHelp module should be built...
Checking to see if the QtMultimedia module should be built...
Checking to see if the QtMultimediaWidgets module should be built...
Checking to see if the QtNetwork module should be built...
Checking to see if the QtOpenGL module should be built...
Checking to see if the QtPrintSupport module should be built...
Checking to see if the QtQml module should be built...
Checking to see if the QtQuick module should be built...
Checking to see if the QtSql module should be built...
Checking to see if the QtSvg module should be built...
Checking to see if the QtTest module should be built...
Checking to see if the QtWebKit module should be built...
Checking to see if the QtWebKitWidgets module should be built...
Checking to see if the QtWidgets module should be built...
Checking to see if the QtXml module should be built...
Checking to see if the QtXmlPatterns module should be built...
Checking to see if the QtDesigner module should be built...
Checking to see if the QAxContainer module should be built...
Checking to see if the QtDBus module should be built...
Checking to see if the _QOpenGLFunctions_ES2 module should be built...
Checking to see if the QtSensors module should be built...
Checking to see if the QtSerialPort module should be built...
Checking to see if the QtX11Extras module should be built...
Checking to see if the QtBluetooth module should be built...
Checking to see if the QtMacExtras module should be built...
Checking to see if the QtPositioning module should be built...
Checking to see if the QtWinExtras module should be built...
Checking to see if the QtQuickWidgets module should be built...
Checking to see if the QtWebSockets module should be built...
Checking to see if the Enginio module should be built...
Checking to see if the QtWebChannel module should be built...
Checking to see if the QtWebEngineWidgets module should be built...
Checking to see if the QtLocation module should be built...
Checking to see if the QtNfc module should be built...
Checking to see if the QtWebEngineCore module should be built...
Checking to see if the QtWebEngine module should be built...
Checking to see if the dbus support module should be built...
DBus v1 does not seem to be installed.
Qt v5.7.1 is being used.
The qmake executable is /usr/bin/qmake.
Qt is built as a shared library.
SIP 4.19.13 is being used.
The sip executable is /home/pi/root/env/py/Qt/bin/sip.
These PyQt5 modules will be built: QtCore, QtGui, QtNetwork, QtOpenGL,
QtPrintSupport, QtSql, QtTest, QtWidgets, QtXml, QtDBus, _QOpenGLFunctions_ES2.
The PyQt5 Python package will be installed in
/home/pi/root/env/py/Qt/lib/python3.7/site-packages.
PyQt5 is being built with generated docstrings.
PyQt5 is being built with 'protected' redefined as 'public'.
The Designer plugin will be installed in
/usr/lib/arm-linux-gnueabihf/qt5/plugins/designer.
The qmlscene plugin will be installed in
/usr/lib/arm-linux-gnueabihf/qt5/plugins/PyQt5.
The PyQt5 PEP 484 stub files will be installed in
/home/pi/root/env/py/Qt/lib/python3.7/site-packages/PyQt5.
The PyQt5 .sip files will be installed in
/home/pi/root/env/py/Qt/share/sip/PyQt5.
pyuic5, pyrcc5 and pylupdate5 will be installed in /home/pi/root/env/py/Qt/bin.
The interpreter used by pyuic5 is /home/pi/root/env/py/Qt/bin/python.
Generating the C++ source for the QtCore module...
Embedding sip flags...
Generating the .pro file for the QtCore module...
Generating the C++ source for the QtGui module...
Generating the .pro file for the QtGui module...
Generating the C++ source for the QtNetwork module...
Generating the .pro file for the QtNetwork module...
Generating the C++ source for the QtOpenGL module...
Generating the .pro file for the QtOpenGL module...
Generating the C++ source for the QtPrintSupport module...
Generating the .pro file for the QtPrintSupport module...
Generating the C++ source for the QtSql module...
Generating the .pro file for the QtSql module...
Generating the C++ source for the QtTest module...
Generating the .pro file for the QtTest module...
Generating the C++ source for the QtWidgets module...
Generating the .pro file for the QtWidgets module...
Generating the C++ source for the QtXml module...
Generating the .pro file for the QtXml module...
Generating the C++ source for the QtDBus module...
Generating the .pro file for the QtDBus module...
Generating the C++ source for the _QOpenGLFunctions_ES2 module...
Generating the .pro file for the _QOpenGLFunctions_ES2 module...
Generating the C++ source for the pylupdate module...
Generating the .pro file for the pylupdate module...
Generating the C++ source for the pyrcc module...
Generating the .pro file for the pyrcc module...
Generating the C++ source for the Qt module...
Generating the .pro file for the Qt module...
Generating the pylupdate5 wrapper...
Generating the pyrcc5 wrapper...
Generating the pyuic5 wrapper...
Generating the top-level .pro file...
Making the pylupdate5 wrapper executable...
Making the pyrcc5 wrapper executable...
Making the pyuic5 wrapper executable...
Generating the Makefiles...

 約5分で完了。

make

(Qt) $ make

 約60〜90分で完了。長い……。

install

$ sudo make install

 約10秒で完了。

確認

$ pip list
Package    Version
---------- -------
pip        10.0.1 
PyQt5      5.11.3 
setuptools 39.0.1 
sip        4.19.13

 PyQt5が追加された。成功!

所感

 ここまで長かった……。