I have a debian package whose content requires that a certain python package is installed with pip installed <python-package>.

How should I precisely configure my .deb package (probably through debian/rules) in order for <python-package> to be installed with the package (i.e when launching dpkg -i mypackage.deb)?

  • IMO this scenario contradicts a purpose of package management. The purpose of sane package management is that while installing a package, you install only the packages which were built on a repository maintained by package maintainers. During a package installation or a build, the package "rules" should not install anything from "unknown" sources or to download some random stuff from internet.
    – jirib
    Feb 26, 2017 at 12:23
  • Packaging that dependency would be a better solution. Feb 27, 2017 at 9:19

2 Answers 2


This is not trivial to do. There are multiple possibilities outlined in this question and its answers, but as @FerencWagner said, the best and most correct solution is to re-package all dependencies as debian packages.

Some python packages are already available as debian packages, like jsonpickle:

$ apt-cache search jsonpickle
python-jsonpickle - Python library for serializing object graphs into JSON (Python 2)
python-jsonpickle-doc - Python library for serializing object graphs into JSON (documentation)
python3-jsonpickle - Python library for serializing object graphs into JSON (Python 3)

So you should search for them first, maybe you don't have to do anything yourself.


Here is a guide for how to package and deploy your python3 application from the host to another linux machine (let's call it machine1).

First I assume your python application is built correctly with a valid setup.py here is the example that I used see link.

  1. Installing your python3 application dependencies:

    1.1. Go to your "foo" application directory where the setup.py is located and run:

    $ cd path_to_foo/foo/
    $ python3 setup.py sdist bdist_wheel

    1.2. It will create a "dist" folder go inside and copy foo-0.1-py3-none-any.whl file to machine1

    1.3. Log into machine1 and go to the path of the whl file and run:

    $ cd path_to_whl_file/
    $ pip3 install foo-0.1-py3-none-any.whl
  2. Installing your python3 application package

    2.1. First we need to install fpm (on your host development machine) look here for more information How To Use FPM To Easily Create Packages in Multiple Formats.

    $ sudo apt-get update
    $ sudo apt-get install ruby-dev build-essential
    $ sudo gem install fpm

    2.2. then go to the directory that holds the foo application and run:

    $ sudo fpm --python-bin python3 --python-pip pip3 \
      --python-package-name-prefix python3 --no-python-dependencies \
      --python-install-bin /usr/bin -s python -t deb \

    It should create the package python3-foo_0.1_all.deb

    2.3. Log into machine1 and go to the path of the deb package and install it

    $ cd path_to_deb_package/
    $ sudo dpkg -i python3-foo-_0.1_all.deb
  3. That's it now you can run the application from anywhere (the application is placed at /usr/bin/)

Hope that answered your question and helped you with creating/building python3 packages.

NOTE: it worked for me on Ubuntu, Debian, and Raspbian.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .