Ubuntu – Anki does not run on Ubuntu 16.10 after upgrade from 16.04

16.10ankiupgrade

after upgrading to Ubuntu 16.10 from 16.04, Anki program does not run. this is the error message:

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

Best Answer

Simple solution (pre-compiled build)

The latest Anki releases are now available as compiled static builds which ship with all dependencies included. They should work right out of the box on most Linux distros.


Advanced solution (using source code tarball)

In some instances it might be necessary to run Anki from source, e.g. when developing an add-on or playing around with Anki's code. In those cases the following should work:

  1. Make sure you have all of Anki's dependencies satisfied (either by looking at the package dependencies and manually installing them, or by installing Anki from the official repositories in order to fetch its dependencies)
  2. Download the latest Anki 2.0.x source tarball from Anki's homepage and extract it
  3. Download the Debian Jessie version of python-qt4, as pointed out by davidbragat below, and extract it
  4. Find the PyQt4 folder located in the extracted python-qt4 debfile and move it to the extracted Anki source folder. In the end, the PyQt4 folder and runanki script should reside next to each other.
  5. Edit runanki in Anki's source folder and change

    import sys
    sys.path.insert(0, "/usr/share/anki")
    

    to

    #import sys
    #sys.path.insert(0, "/usr/share/anki")
    
  6. cd to Anki's source code folder and run ./runanki. Anki should now launch.