Skip to content

Ubuntu Installation Experience

Jorj X. McKie edited this page Feb 10, 2018 · 14 revisions

Updated: 10Feb2018

MuPDF 1.12.0, PyMuPDF 1.12.2

Instructions

This is a list of steps that should lead to a successfully installed PyMuPDF. It has been tested on Ubuntu 16.04, 16.10, and 17.10 with Python 3.6, but it should work with other version combinations, too.

  • Get the MuPDF source from the site wget https://mupdf.com/downloads/mupdf-1.12.0-source.tar.gz (latest version as of writing. Others available here: https://mupdf.com/downloads/archive/).
  • MuPDF also has a repository on GitHub. This, however, is the latest development version! Do not use it: it may not be compatible with PyMuPDF.
  • Once unpacked, modify the Makerules file by adding -fPIC to the CFLAGS so: CFLAGS += -Wall -fPIC (this is near the top of the file so no need to search).
  • Run the initial make: make HAVE_X11=no HAVE_GLFW=no HAVE_GLUT=no prefix=/usr/local
  • If no issues occur install: make HAVE_X11=no HAVE_GLFW=no HAVE_GLUT=no prefix=/usr/local install
  • Get the corresponding version of PyMuPDF: git clone -b <correct branch> https://github.com/rk700/PyMuPDF.git (<correct branch> should match mutool version).
  • Edit the setup.py to point to the correct directories as indicated by the prefix used when making.

Here is the resp. code snippet:

...
include_dirs=['/usr/local/include/mupdf',    # we need the path of the MuPDF and zlib$
              '/usr/local/thirdparty/zlib',  # '/usr/include/mupdf',
             ],
library_dirs=['/usr/local/lib'],
libraries=['mupdf',
            #'crypto', #openssl is required by mupdf on archlinux
            #'jbig2dec', 'openjp2', 'jpeg', 'freetype',
           'mupdfthird',
          ], # the libraries to link with
...

(Comment unnecessary libraries out)

  • Run python setup.py build

If no exception is thrown install either with python setup.py install or pip install.

Clone this wiki locally