10
8

More than 5 years have passed since last update.

PyQt5.12でWebEngineWidgetsが分離された

Posted at

PyQt5

PyQtはアプレット等GUIを作るのに便利なモジュールである。これの良いところは依存関係が少ないところ(現状2019年3月現在、PyQt5-sipだけ)で、クローズドな環境でも導入しやすい。
また、PyQt5さえ入れておけば、かなりのmoduleを呼び出せたのでお気に入りだった。

PyQt5からmoduleの分離

バージョンを5.12にあげたころから、下記のエラーが出るようになった。

>>> import PyQt5.WebEngineWidgets
ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidgets'

5.11までで通っていたので、何やら変更があった模様である。
結論から述べると、WebEngineWidgetsが別のmoduleとして扱われるようになった。
なので、以下のlibraryをインストールすれば良い。

$ pip install PyQtWebEngine
Successfully installed PyQtWebEngine-5.12.1
$ pip show PyQtWebEngine
Name: PyQtWebEngine
Version: 5.12.1
Summary: Python bindings for the Qt WebEngine framework
Home-page: https://www.riverbankcomputing.com/software/pyqtwebengine/
Author: Riverbank Computing Limited
Author-email: info@riverbankcomputing.com
License: GPL v3
Location: /Users/hikaru/.pyenv/versions/3.6.1/lib/python3.6/site-packages
Requires: PyQt5
Required-by: 

2つ目のコマンドは、パッケージ情報の確認である。
確かに、これでWebEngineWidgetsが使えるようになった。

この変更についてask ubuntuでも質問されている

PyQt5.12の仕様変更について

公式を見ると、PyQt5.12リリースに合わせて、PyQtWebEngine以外にも複数のlibraryがリリースされたことがわかる。
PyQtWebEngineに移されたmoduleについては、パッケージが変わっただけで、アプリ側の実装には影響しないとのこと。
しかし、この変更の理由自体はよくわからず。
確かにPyQt5パッケージ自体は軽量化されたが、公式見解について記載があると嬉しい。

10
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
8