Getting Anki 2.0 to work with Debian stretch
Posted on August 3, 2016
Recent updates to Debian testing (aka stretch) have rendered Anki broken, with the following error message at startup:
$ anki
Traceback (most recent call last):
File "/usr/bin/anki", line 7, in <module>
import aqt
File "/usr/share/anki/aqt/__init__.py", line 12, in <module>
from aqt.qt import *
File "/usr/share/anki/aqt/qt.py", line 22, in <module>
from PyQt4.QtWebKit import QWebPage, QWebView, QWebSettings
ImportError: No module named QtWebKit
This problem apparently occurs in recent versions of Ubuntu, as well.
As explained in Debian bug #826727, the problem is that “QtWebKit was removed from the Qt4 in Debian. There is no fix other than a Qt5 port of anki.”
Fortunately, that’s not the only solution, from the perspective of Anki users. The Anki web site gives us a clue, but it’s not very complete, so these instructions should get you all of the way there.
-
Download a working version of
python-qt4
. The version number is particularly important. I found that 4.11.4+dfsg-1 works for me, whereas 4.11.4+dfsg-2 does not! I also downloaded the matching version of python-qt4-sql. If you have other python packages installed that depend on a properly matching version, look for them here.wget http://snapshot.debian.org/archive/debian/20150613T221652Z/pool/main/p/python-qt4/python-qt4_4.11.4%2Bdfsg-1_amd64.deb wget http://snapshot.debian.org/archive/debian/20150613T221652Z/pool/main/p/python-qt4/python-qt4-sql_4.11.4%2Bdfsg-1_amd64.deb
-
Install the newly-downloaded old packages:
sudo dpkg -i python-qt4_4.11.4+dfsg-1_amd64.deb python-qt4-sql_4.11.4+dfsg-1_amd64.deb
-
Hold the package, so your next upgrade won’t break Anki again!
sudo aptitude hold python-qt4
That should do it. Try starting Anki again!
Filed under: Anki debian language learning Linux