Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ubuntu Installation Experience

Julian Smith edited this page Jun 27, 2022 · 14 revisions

Updated: 2022年06月27日

Since PyMuPDF-1.20.0 (released 2022年06月17日), there is no need to manually download and build MuPDF when building PyMuPDF.

Updated: 08 Jul 2021

MuPDF 1.18.0, PyMuPDF 1.18.14

Instructions

This is a list of steps that should lead to a successfully installed PyMuPDF.

  • Get the MuPDF source from the site wget https://mupdf.com/downloads/archive/mupdf-1.14.0-source.tar.gz and decompress it (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 is probably not be compatible with the current PyMuPDF.
  • Set environment variables: export CFLAGS="-fPIC" (on CentOS 5, export CFLAGS="-fPIC -std=gnu99" to resolve errors about missing a definition for NAN symbol in the thirdparty/mujs folder). If you do not set the CFLAG -fPIC, you may also run into a linking error when you run setup.py.
  • Run the initial make: sudo make HAVE_X11=no HAVE_GLFW=no HAVE_GLUT=no prefix=/usr/local
  • If no issues occur install: sudo make HAVE_X11=no HAVE_GLFW=no HAVE_GLUT=no prefix=/usr/local install
  • You may need to pass in XCFLAGS during the make process if python setup.py build fails to link the binaries (this step is below).
  • If you do get a linking issue, try this installation command instead: make HAVE_X11=no HAVE_GLUT=no XCFLAGS="-fPIC" prefix=/usr/local install
  • Remember, you may need to use sudo for installation, as it writes the mupdf executable to /usr/local, which usually require root access to read/write from. If you don't the previous make commands may fail.
  • 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',
 'mupdf-third', # the '-' is new in v1.14.0
 ], # 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.


Alternative method

The following worked for me on Ubuntu 18.04.3 LTS, after having no luck with the above.

sudo apt install python3-pip
sudo -H pip3 install --upgrade pip
sudo -H python3.6 -m pip install -U pymupdf

Recipes

HOWTO Button annots with JavaScript

HOWTO extract images

HOWTO join PDFs

HOWTO work with PDF embedded files

HOWTO Convert Images

HOWTO extract text from inside rectangles

HOWTO extract text in natural reading order

HOWTO add PDF form fields

HOWTO deal with annotations

HOWTO convert to PDF

HOWTO show PDF Form fields

HOWTO work with vector images

HOWTO create or extract graphics

HOWTO create your own PDF Drawing

HOWTO add pages, images, text

HOWTO extract fonts

HOWTO rearrange pages

HOWTO GUI PDF display

Algebra with geometry objects

Rectangle inclusion & intersection

Hyperlink maintenance

Visual table extraction

Incremental saves

Metadata & bookmark maintenance

Wrapping FileOptimizer

Installation

Ubuntu

Ubuntu Installation Experience

Windows Binaries

Windows Binaries Generation

Windows Binaries Installation

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /