Linux application deployment

P at P at
Mon Sep 6 18:49:39 CEST 2004

Alex Martelli wrote:
> Robert M. Emmons <RobMEmmons at> wrote:
>    ...
>>One thing I've always wonders was -- Is there a way for a python module
>>to tell where it's file is located???  If you could do this it might 
> Piece of cake: the key part of this recipe is
>     def whereami(): return sys.modules[__name__].__file__
> then you can os.path.abspath this filename string as you wish.

That only seems to work for python 2.3 or later

One thing to consider when wondering where to put system wide
modules is that you have to worry about the python version
changing underneath you. This is because *.py[oc]
are not compatibile across minor version changes.

I.E. if one has pyc files in /usr/lib/site-python
and python 2.3 is installed subsequently on the system
then the modules probably will cause problems.

That is why py[co] files are installed in
version specific directories like:


More information about the Python-list mailing list