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!
What do you study with Anki?
Language vocabulary. Spanish, Portuguese, French, Dutch, Latin, and English. 🙂
Thank you so much, you saved my life.
It works in Deepin15.3! Thanks so much.
thank you very much for this, just a question, does the aptitude hold command works only for updates through aptitude or it works through apt-get too ?
For apt-get, I believe you need to use `apt-mark hold`. See this answer on Stack Exchange: http://askubuntu.com/a/18656/20104
Many thanks,
I was desperate to have Anki on Debian 9. But to make it work, I had to install this :
libqtwebkit4_2.2.1-5_amd64.deb also
Thank you very much for this elegant how-to!
During the install I ran into some errors:
===
dpkg: error processing package python-qt4 (–install):
dependency problems – leaving unconfigured
dpkg: dependency problems prevent configuration of python-qt4-sql:
python-qt4-sql depends on python-qt4 (= 4.11.4+dfsg-1); however:
Package python-qt4 is not configured yet.
python-qt4-sql depends on libqt4-sql (>= 4:4.8.0-1~); however:
Package libqt4-sql is not installed.
dpkg: error processing package python-qt4-sql (–install):
dependency problems – leaving unconfigured
Errors were encountered while processing:
python-qt4
python-qt4-sql
===
If you are sceptical: proceed. It works anyway.