I have the following problem: I'm running debian 9 installation from a custom created iso with additional packages. One of the packages runs in the postinst script a python command defined in this packages, but the postinst script fails with error:

my-command command not found

therefore all software installation step fails. my-package.postinst:


When postinst is commented out all the process finishes successfully. Even when the process failed ( dpkg -l return my_package in status iF) after a reboot, it is possible to run my-command from command line.
I guess the problem is in python packages which are not properly installed during running my-package.postinst, but even moving them to pre-depend did not help.
Any ideas or directions? Any help will be appreciated.
Thank you in advance, Veronika

The custom Debian 9 iso disc is created using simple-cdd.

pkg-root/DEBIAN/control of my-package:

Package: my-package
Version: 1.0
Priority: optional
Architecture: all
Depends: geoip-bin, openssh-server, ntp, sshguard, lsb-release, vim, less, nload, iotop, logrotate, passwd, python-requests
Pre-depends: python, apt-transport-https, iproute2, python-setuptools


from setuptools import setup

    namespace_packages=['MyModules', 'MyModules.System'],
        "console_scripts": [
            "my-command = MyModules.System.Tools:cli_my_command"


during packaging the following command is run to create relevant entry_points,dependency_links, namespace_packages:

 python setup.py install -f --install-layout=deb --prefix=/usr/local --root=pkg-root
  • Not sure if I'm understanding your exact problem... But have you tried specifying the full path to my-command in my-package.postinst.
    – Peschke
    Jul 23 '19 at 22:22
  • my-command defined as cli command. my-packages supposes to define it by copying my-command file into /usr/local/bin. The command is fully available after the package installation, even though the package itself is failed. Only during debian installation I get an error of postinst script "command not found".
    – Veronika U
    Jul 24 '19 at 7:06
  • After changing my-package.postinst to : #!/bin/bash python <full path to cli function> package installation runs as expected. So the problem somewhere withing python-setuptools . After the installation running cli command works
    – Veronika U
    Aug 7 '19 at 8:01

As all python packages were installed properly, the only problem that caused not finding the cli command was in PATH variable - it did not include at this step the location of my-command (/usr/local/bin - seems it is added later). The solution was adding this: export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin in my-package.postinst script before running my-command.

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.