Anki fails to start because QWebEngineView is not defined (missing import)

Bug #1825722 reported by Fiona Klute
38
This bug affects 8 people
Affects Status Importance Assigned to Milestone
anki (Ubuntu)
Fix Released
High
Unassigned
Disco
Fix Released
High
Unassigned
Eoan
Fix Released
High
Unassigned

Bug Description

[Impact]

Due to changes in PyQt (according to Arch), the Anki application fails to run because library imports have been altered in a way that causes the application to not execute and start under any circumstances.

This makes the application as is currently unusable.

[Test Case]

(1) Install Ubuntu Disco or Ubuntu Eoan.

(2) Install anki from repositories as-is (2.1.8+dfsg-1)

(3) Attempt to run `anki` on command line, you get the traceback stated in the original description.

(4) Use the PPA or the version in the repos/proposed.

(5) Anki properly runs without error and starts up as expected.

[Regression Potential]

From a code perspective, the only thing we do is we pull in all the libraries and classes from PyQt5.QtWebEngineWidgets. In the long term this could cause breakages if PyQt changes again.

However, in the intervening *short term*, this change does not introduce any major code or functional changes other than to make the various classes available for use, and the regression risk from this change is minimal.

[Additional Information]

This was tested in a Disco and an Eoan VM running inside VMware. The test cases were both able to be tested without issue there, and are as written.

There is a PPA with these changes available, linked in the comments.

[Original Description]

Trying to start Anki version 2.1.8+dfsg-1 from Ubuntu 19.04 fails with the following error:

Traceback (most recent call last):
  File "/usr/bin/anki", line 6, in <module>
    import aqt
  File "/usr/share/anki/aqt/__init__.py", line 32, in <module>
    import aqt.forms
  File "/usr/share/anki/aqt/forms/__init__.py", line 44, in <module>
    from . import about
  File "/usr/share/anki/aqt/forms/about.py", line 42, in <module>
    from aqt.webview import AnkiWebView
  File "/usr/share/anki/aqt/webview.py", line 90, in <module>
    class AnkiWebView(QWebEngineView):
NameError: name 'QWebEngineView' is not defined

This appears to be due to changes in the PyQt, as described in this Arch bug report: https://bugs.archlinux.org/task/61710

The patch suggested there by Antonio Rojas works on my Ubuntu 19.04 system, too:

--- /usr/share/anki/aqt/qt.py.orig 2019-02-10 22:41:21.648827256 +0100
+++ /usr/share/anki/aqt/qt.py 2019-02-10 22:38:17.798020886 +0100
@@ -13,7 +13,7 @@
from PyQt5.Qt import *
# trigger explicit message in case of missing libraries
# instead of silently failing to import
-from PyQt5.QtWebEngineWidgets import QWebEnginePage
+from PyQt5.QtWebEngineWidgets import *
try:
from PyQt5 import sip
except ImportError:

tags: added: disco patch
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in anki (Ubuntu):
status: New → Confirmed
Revision history for this message
Benjamin.M (benjaminm) wrote :

Proposed fix also worked for me. But look & feel of app is quite ugly. Are there maybe different skins/themes? I.e. a GTK3 CSS.

Revision history for this message
Thomas Ward (teward) wrote :

Is this issue specific to Disco and Eoan? Or does this happen in other releases as well?

Changed in anki (Ubuntu Disco):
status: New → Confirmed
importance: Undecided → Medium
Changed in anki (Ubuntu Eoan):
importance: Undecided → Medium
Changed in anki (Ubuntu Disco):
assignee: nobody → Thomas Ward (teward)
Changed in anki (Ubuntu Eoan):
assignee: nobody → Thomas Ward (teward)
Revision history for this message
Thomas Ward (teward) wrote :

To those affected, there are Disco and Eoan builds here for testing: https://launchpad.net/~teward/+archive/ubuntu/anki-1825722

They include the aforementioned patch with a few tweaks to be Debian packaging compatible.

They should be testable within an hour, please test the packages to see if this solves the issue on Disco and Eoan. (This issue has not been confirmed to be on any other releases of Ubuntu at this time, so those have not been added to the PPA yet.)

Revision history for this message
Thomas Ward (teward) wrote :

I did my testing locally in an Eoan and a Disco VM, and this fix does indeed work.

Further, I dug into the imports, we would need to import a long string of plugin bits to import each bit individually, so since we're past 3 or 4 imports at that point it makes sense and is easier to just import * to import the entire set of QtWeb bits that the program is going to use.

I've taken the patch and adjusted it to be compliant with SRU requirements and Packaging requirements. I will upload this to Eoan and prep the SRU as well.

Changed in anki (Ubuntu Disco):
importance: Medium → High
Changed in anki (Ubuntu Eoan):
importance: Medium → High
Revision history for this message
Thomas Ward (teward) wrote :

SRU template applied.

Changed in anki (Ubuntu Eoan):
status: Confirmed → Fix Committed
description: updated
Thomas Ward (teward)
Changed in anki (Ubuntu Disco):
assignee: Thomas Ward (teward) → nobody
status: Confirmed → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package anki - 2.1.8+dfsg-1ubuntu1

---------------
anki (2.1.8+dfsg-1ubuntu1) eoan; urgency=medium

  * d/patches/QWebEngineView-import-fix.patch: Apply Arch-originating
    patch to aqt/qt.py to use a wildcard import to fetch all web engine
    plugins in order to get QWebEngineView imported, to fix a crash that
    prevents running anki. (LP: #1825722)

 -- Thomas Ward <email address hidden> Mon, 01 Jul 2019 13:03:33 -0400

Changed in anki (Ubuntu Eoan):
status: Fix Committed → Fix Released
Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello Fiona, or anyone else affected,

Accepted anki into disco-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/anki/2.1.8+dfsg-1ubuntu0.19.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-disco to verification-done-disco. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-disco. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in anki (Ubuntu Disco):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-disco
Thomas Ward (teward)
Changed in anki (Ubuntu Eoan):
assignee: Thomas Ward (teward) → nobody
Revision history for this message
Fiona Klute (fiona-klute) wrote :

I've installed and successfully tested anki 2.1.8+dfsg-1ubuntu0.19.04.1. Testing included my usual use of anki:

* Program start
* Using multiple flashcard sets
* Viewing statistics

Thanks for the fix!

tags: added: verification-done-disco
removed: verification-needed-disco
Revision history for this message
Thomas Ward (teward) wrote :

I went ahead and also confirmed the verification was completed for anki in Disco Proposed.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package anki - 2.1.8+dfsg-1ubuntu0.19.04.1

---------------
anki (2.1.8+dfsg-1ubuntu0.19.04.1) disco; urgency=medium

  * d/patches/QWebEngineView-import-fix.patch: Apply Arch-originating
    patch to aqt/qt.py to use a wildcard import to fetch all web engine
    plugins in order to get QWebEngineView imported, to fix a crash that
    prevents running anki. (LP: #1825722)

 -- Thomas Ward <email address hidden> Mon, 01 Jul 2019 13:03:33 -0400

Changed in anki (Ubuntu Disco):
status: Fix Committed → Fix Released
Revision history for this message
Brian Murray (brian-murray) wrote : Update Released

The verification of the Stable Release Update for anki has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Carlos Pita (carlosjosepita) wrote :

This worked for me, thanks! Anyway, I would like to point out that this is a problem upstream and it would be nice to port the fix to Debian. I have emailed the maintainer a couple of times because of this issue but never got an answer. It would safe to consider upstream to be unmaintained at this point, I guess.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.