# Paperwork installation on GNU/Linux Debian or GNU/Linux Ubuntu

## Package

Currently, there is no official Debian or Ubuntu package for Paperwork.

Therefore on Debian or Ubuntu it is recommended to use the
[Flatpak package](https://gitlab.gnome.org/World/OpenPaperwork/paperwork/blob/master/flatpak/README.markdown#readme)
instead of the following instructions.

The following instructions describe how to install Paperwork the Python way.


## Libinsane

If you want to install Paperwork, you must first
[install Libinsane](https://doc.openpaper.work/libinsane/latest/libinsane/install.html).
Libinsane is *not* a Python module but a C library. It cannot be found on
pypi.org and *cannot* be installed automatically with the command `pip`.


## Build dependencies

    sudo apt install python3-pip python3-setuptools
    sudo apt install python3-dev python3-pil

    # PyEnchant dependency
    sudo apt install libenchant-dev

    # Not a build dependency, but recommended anyway
    sudo apt install python3-whoosh


## System-wide installation

(this is the recommended method by default)

You can then install paperwork using pip:

    sudo pip3 install paperwork

Some dependencies cannot be installed automatically, because they depend on
your language. You can find all the required dependencies not yet installed by
running 'paperwork-chkdeps'

    paperwork-shell chkdeps paperwork_backend
    paperwork-shell chkdeps paperwork

Since Paperwork 1.2, you can add a Paperwork shortcut in your desktop menus
with the following command:

    paperwork-shell install


## Virtual env

If you're reluctant to install system wide python libraries, you can use
[Python Virtualenv](install.devel.markdown). Note that using this method
you cannot have shortcuts installed on your system automatically.


## Install through packages generated by python-stdeb

If you're reluctant to install system wide python libraries through pip,
you can also use debian packages generated on the fly by [python-stdeb](https://pypi.python.org/pypi/stdeb)

You will still have to install
[Libinsane](https://doc.openpaper.work/libinsane/latest/libinsane/install.html)
manually.

Also, Debian doesn't provide yet the command `pypi-install` for Python 3.
Therefore it has first to be installed... manually.

    sudo apt install python3-all-dev python3-pip
    sudo apt install python3-{pyocr,enchant,levenshtein,natsort,pycountry,termcolor}
    sudo pip3 install stdeb

Then you can generate and install the packages for Paperwork libraires:

    sudo /usr/local/bin/pypi-install --release 1.3.7 nose
    sudo /usr/local/bin/pypi-install pypillowfight
    sudo /usr/local/bin/pypi-install simplebayes

And then you can generate and install the packages for Paperwork itself:

    sudo /usr/local/bin/pypi-install paperwork-backend
    sudo /usr/local/bin/pypi-install paperwork

Finally, you have to run the following commands to check some extra dependencies:

    paperwork-shell chkdeps paperwork_backend
    paperwork-shell chkdeps paperwork

And the menu entry:

    paperwork-shell install


## Running Paperwork

If you used `paperwork-shell install`, a shortcut should be available in the
menus of your window manager (you may have to log out first).

You can also start Paperwork by running the command `paperwork`.

Enjoy :-)
