I have a single python script that I want to distribute as a deb package. It is a indicator which shows local date in Unity panel. I did follow create a .deb Package from scripts or binaries but I could not create a deb package because it fails.

Can someone give me a step-by-step instruction on what I should do? As far as I know this script depends on python-appindicator.

I do not want any links to Debian/Ubuntu packaging instructions. I have seen most of them. I don't find them beginner friendly.

  • 6
    While Debian and Ubuntu packaging instructions aren't beginner friendly (trust me, I know), many GUI applications that create debs for you just turn up a bunch of errors when you run a final package checker, such as lintian. If you're serious about packaging, then toughing it out and working through the instructions is the best way to go :) Dec 30 '11 at 14:03
  • I don't know about packaging, but the functionality you are trying to add is built in to Unity. Jun 7 '15 at 1:12

What follows is a basic example of how a source package for a python script might look. While most of the packaging tutorials are a bit complex, they can really help if you hit a problem. That said, I first learned the basics of Debian packaging by simply looking at Debian packages. apt-get source something similar and learn by example.

Here's your basic source package layout:

    -- myScript
    -- debian/
        -- changelog
        -- copyright
        -- compat
        -- rules
        -- control
        -- install

Run dch --create in the directory to create a properly formatted debian/changelog entry.

debian/copyright should look like:

Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: myScript
Upstream-Contact: Name, <email@address>

Files: *
Copyright: 2011, Name, <email@address>
License: (GPL-2+ | LGPL-2 | GPL-3 | whatever)
 Full text of licence.
 Unless there is a it can be found in /usr/share/common-licenses

debian/compat can just be: 7


#!/usr/bin/make -f

    dh $@ --with python2

Note that there must be "tab" before dh $@ --with python2, not spaces.


Source: my-script
Section: python
Priority: optional
Maintainer: Name, <email@address>
Build-Depends: debhelper (>= 7),
               python (>= 2.6.6-3~)
Standards-Version: 3.9.2
X-Python-Version: >= 2.6

Package: my-script
Architecture: all
Section: python
Depends: python-appindicator, ${misc:Depends}, ${python:Depends}
Description: short description
 A long description goes here.
 It can contain multiple paragraphs


myScript usr/bin/

This file indicates which file will be installed into which folder.

Now build it with debuild --no-tgz-check

This will create a functional deb package. Lintian is going to throw a few warnings regarding the lack of an orig.tar.gz, but unless you plan on creating a proper upstream project that makes tarball releases you'll probably just want to ignore that for now.

  • 16
    As a packager (and a backporter), I package python scripts fairly often. I can safely say that this answer here is the most complete explanation of what to do to create a package for a single python script.
    – Thomas Ward
    Dec 31 '11 at 0:24
  • 2
    Could you also update it for Python 3? I guess we need to make changes in debian/rules and debian/control, but I am not sure about that.
    – Aditya
    Jan 3 '14 at 16:14
  • 1
    @Aditya, maybe a new question is in order for Python3? The answer wouldn't be very different, but this answer is aiming to be the simplest/bare minimum example of how to package a Python script. Not sure I want to clutter it up with multiple implementations. Jan 3 '14 at 16:48
  • 1
    What about the libraries? If the python script imports libraries then it won't work
    – D.Snap
    Mar 16 '16 at 9:20
  • 1
    debian.org/doc/manuals/maint-guide/dother.en.html#compat Says that its better to set compat to 10 and not 7.
    – danger89
    Sep 23 '20 at 1:24
  1. create a folder with any name on your home eg: mypyscript
  2. Open the folder and create two folders with names 'DEBIAN' and 'usr'
  3. Open the folder DEBIAN. Create a text file (without extension) with name 'control' there.
  4. Open 'control' and type as follows and save it on DEBIAN

    Package: mypyscript
    Version: 0.01
    Architecture: all
    Maintainer: your name<your mail id>
    Installed-Size: 2
    Depends: python-appindicator
    Section: extras
    Priority: optional
    Homepage: your homepage
    Description: describe
  5. Back to the folder named mypyscript. Open 'usr'. Create a folder named 'bin'. Open 'bin' and paste your pythonscript file there.

  6. You can also make a menu entry. But that is not essential.
  7. Back to the home folder where the folder 'mypyscript' lies or close the file browser.
  8. Open terminal. Be sure that terminal is in the home folder. type dpkg -b mypyscript .Then press enter. In seconds your deb package is ready

note: please fill the 'control' file properly. Don't use apostrophes. It is only for indicating the names.

  • 1
    Works great! The accepted answer is complex.
    – SuB
    Jan 8 '14 at 13:24
  • Don't forget to change permission of 'myscript' to 755 and the owner of it to root.
    – SuB
    Jan 8 '14 at 13:33
  • How do I create a menu entry?
    – To Do
    Jul 2 '14 at 8:52

You could try with Debreate, a GUI tool for creating packages.

  • Debcreate is cool. I like it so far, just started using it today to build from python source code. Mar 16 '17 at 0:01
  • Haven't tried it but it looks perfect for my python scripts. Note it doesn't support compiling code which isn't an issue for python scripts. Mar 22 at 22:38

I would check out quickly, great for creating quick apps and generating debs google it or you can find tutorials here http://developer.ubuntu.com/


Try pkgme. It's supposed to Just Work.

Install via:

sudo apt install pkgme

Run via:


(A new developer may have to run gpg --gen-key, see Development Keysigning to do this correctly)


Meanwhile there is an article describing the dilemma found on https://www.nylas.com/blog/packaging-deploying-python/. It mainly states that there is dh-virtualenv working together with make-deb to easily deploy Python code just using a setup.py file. A short manual can be found on https://gist.github.com/JeOam/bc6cbf38f04d6f9dbf81


You could try using Debreate

This is a Gui Interface to create packages and stuff you can use the PPA also if you dont want to download it from the website that is listed above.

sudo add-apt-repository ppa:antumdeluge/<ppaname>; sudo apt update; sudo apt install debreate

Ive condenced the ppa so that it runs as one single line of code! Thanks for the awesome question and be sure to keep bopping those lines of code into the terminal!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.