How to compile, install and debug Calibre in your favorite IDE

Calibre is a very nice e-book organizer, however development documentation is, quite laconic.

Installing it for the first time turned out to be a major pain, when I installed it for the first time, as I had to do some experimentation.

I have installed calibre to a virtual environment, which also is a pain. Nevertheless here is what to do.

  1. Download calibre source

    git clone
  2. Install all system dependencies (there quite many of them). For systems not based on Debian install them by hand.

    sudo aptitude build-dep calibre
  3. Create a virtual environment. You'll have to pass --system-site-packages switch that allows virtualenv to use system python packages.

    cd calibre
    virtualenv -p python2 --system-site-packages venv
    source venv/bin/activate
  4. Try to launch

    Traceback (most recent call last):
      File "/tmp/calibre2/setup/", line 103, in get_sip_dir
    EnvironmentError: Failed to find the location of the PyQt5 .sip files

    Calibre can't find system SIP files for PyQt5, you'll need to edit setup/ find a line that contains:

    pyqt['pyqt_sip_dir'] = get_sip_dir(sys.prefix if iswindows else os.path.join(sys.prefix, 'share', 'sip'))

    and replace it with:

    pyqt['pyqt_sip_dir'] = get_sip_dir(sys.prefix if iswindows else os.path.join('/usr/', 'share', 'sip'))

    Just replace sys.prefix to /usr, if you installed PyQt and other dependencies for calibre should work now

  5. Launch python  bootstrap. This command does some stuff I don't really understand, but it is necessary to build calibre.

  6. Install Calibre in development mode: python develop.

  7. Now to debug Calibre you'll just need to launch venv/bin/calibre in debug mode in your favorite IDE.