Skip to content

OCR D on Debian and Ubuntu

Stefan Weil edited this page Jun 8, 2022 · 13 revisions

Using OCR-D on Debian GNU Linux, Linux Mint and Ubuntu

OCR-D can be installed on different versions of Debian, Mint and Ubuntu for Intel / AMD hosts. Installation on other host architectures like ARM or PowerPC works partially and is addressed separately:

Preconditions

Common preconditions

The installation requires lots of free disk space (more than 20 GiB should be free).

Debian

Debian 9 (Stretch) and older versions are too old to be usable with OCR-D.

Debian 10 (Buster) is known to work without special preconditions.

Debian 11 (Bullseye) and newer versions provide Python 3.8 which currently does not work with all parts of OCR-D. With an additional installation of Python 3.7, all parts of OCR-D work.

Linux Mint

Linux Mint 20 Ulyana and newer versions provide Python 3.8 which currently does not work with all parts of OCR-D. With an additional installation of Python 3.7, all parts of OCR-D work.

Ubuntu

Ubuntu 18.04 LTS (Bionic Beaver) is the officially supported Linux distribution for OCR-D. The installation therefore does not require any special preconditions.

Ubuntu 20.04 LTS (Focal Fossa) provides Python 3.8, Ubuntu 22.04 (Jammy Jellyfish) comes with Python 3.10. Both Python versions currently do not work with all parts of OCR-D. With an additional installation of Python 3.7, all parts of OCR-D work.

Running OCR-D tools on Debian or Ubuntu

Installation of Python 3.7

An additional local installation of Python 3.7 is required for all distributions which only provide Python 3.8 or even newer versions of Python.

Do not install the python3.7 package from your distribution if there is already an installation of python3.8. Virtual Python environments for Python 3.7 cannot be created with that combination.

Instead of a pre-packaged Python 3.7, it can be built using these commands:

# Get the Python C code.
mkdir -p $HOME/src/github/python
cd $HOME/src/github/python
# Clone the Python 3.7 branch.
git clone -b 3.7 https://github.com/python/cpython.git
cd cpython

# Install packages which are required for the build.
sudo .github/workflows/posix-deps-apt.sh

# Configure and build in a subdirectory, and install in $HOME.
mkdir bin
cd bin
../configure --prefix=$HOME
make install

# Optionally remove some links which conflict with the pre-installed Python provided by the distribution.
rm -iv $HOME/bin/*3 $HOME/bin/python3-config

Installation of OCR-D tools

Start with these commands from the shell:

mkdir -p $HOME/src/github/OCR-D
cd $HOME/src/github/OCR-D

# Get OCRD/ocrd_all.
git clone https://github.com/OCR-D/ocrd_all.git

cd $HOME/src/github/OCR-D/ocrd_all

# For newer distributions with a locally built Python 3.7,
# that must be used explicitly to create a virtual environment.
# Skip the next three commands for distributions which already
# provide Python 3.6 or Python 3.7.
python3.7 -m venv $HOME/src/github/OCR-D/ocrd_all/venv
source $HOME/src/github/OCR-D/ocrd_all/venv/bin/activate
pip install --upgrade pip

# Build the OCR-D tools. This takes some time.
sudo make deps-ubuntu
make all

Each command should work without showing an error message. Activate the virtual Python environment with all OCR-D tools:

source $HOME/src/github/OCR-D/ocrd_all/venv/bin/activate

Now you are ready to run the OCR-D tools. Try to run one of them:

ocrd --help

Congratulation if that works. You are now ready to use the OCR-D tools. Each time when you open a new shell and want to work with OCR-D tools, you must activate the virtual Python environment again:

source $HOME/src/github/OCR-D/ocrd_all/venv/bin/activate

Welcome to the OCR-D wiki, a companion to the OCR-D website.

Articles and tutorials
Discussions
Expert section on OCR-D- workflows
Particular workflow steps
Recommended workflows
Workflow Guide
Videos
Section on Ground Truth
Clone this wiki locally