I'm currently building a project that imply sources from different languages such as C, C++ and some homemade python module. I'm using Automake/Autotools to install the sources. Problem here is when i'm building a .deb out of this i have some problems.

  • Installation

Python installation is performed like this in my Makefile.am

$(PYTHON) setup.py install \
    --prefix $(DESTDIR)$(prefix) \
    --record $(DESTDIR)$(sysconfdir)/nina/nina_installed_files.txt \

Which is working perfectly when running make install (installation path : /usr/local/lib/python2.7/dist-packages)

But, when i'm packaging the .deb with dpkg-buildpackage commands, it's installing package at /usr/lib/python2.7/site-package which is not in pythonpath. I saw that you can append some path to python path, but i don't want to change .bashrc if it's not absolutely necessary.

Ideadly i'd like to find a way to install python module at /usr/lib/python2.7/dist-packages but python setup.py install doesn't allow full installation path argument.

PS : i alrealy tried --root $(DESTDIR) argument instead of --prefix, but this way is installing in /usr/local/lib/python2.7/dist-packages. And install some files in /usr/local is contrary to .deb packaging rules. Plus it doesn't work with autotools this way.

  • Where is setup.py comming from, can you post the code?
    – Michael D.
    Mar 16, 2017 at 8:59
  • setup.py is the install program of a python module that i've made myself. It aims to wraps some C functions to make them avaiable for another python program. this is the code # -*- coding: utf-8 -*- from distutils.core import setup, Extension # define the extension module uinput_wrapping_module = Extension('uinput_wrapping_module', sources=['uinput_wrapping_module.c','write_keyboard.c','timed_keystrokes.c','manage_devices.c']) # run the setup setup(ext_modules=[uinput_wrapping_module], name='name', version=1, description='Wrapped C', url='', )
    – Neah-Ko
    Mar 21, 2017 at 8:03

1 Answer 1



It seems that it's depending on the distribution, whether modules are located in dist-packages or site-packages.

I found this post in SO which might help.


python -c "import sys;print(sys.path)"


[(..),'/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', (..)]

Packages are installed in /usr/lib/python2.7/dist-packages


.. returns

[(..), '/usr/lib64/python2.7/site-packages', '/usr/lib/python2.7/site-packages']

Packages are installed in both directories.

  • That would be true on another distro than Debian, but when i print my full pythonpath : ~$ python -c "import sys; print sys.path" ['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/gtk-2.0'] No trace of /usr/lib/python2.7/site-packages ....
    – Neah-Ko
    Mar 15, 2017 at 16:17
  • ... This post : stackoverflow.com/questions/9387928/… tells that if I install things from sources it should use site-packages but, it's not even in pythonpath. (I'm on debian stretch, if it has its importance.)
    – Neah-Ko
    Mar 15, 2017 at 16:18
  • You're right, when i'm installing manually the module with sudo python setup.py install --prefix=/usr it's installing in /usr/lib/python2.7/site-packages and python still can't find it. I'm lost here, why python is installing things where it cannot find it ?
    – Neah-Ko
    Mar 15, 2017 at 16:27
  • I've updated my answer
    – Michael D.
    Mar 15, 2017 at 17:23
  • I know that this problem is only present on Debian like distributions, it's the only one that separates dist-packages and site-packages.
    – Neah-Ko
    Mar 15, 2017 at 18:25

You must log in to answer this question.

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