Python sys.prefix

zachar at awst.at zachar at awst.at
Thu Jan 21 11:56:55 EST 2010


Hi All,

I need some help about my "problem":
I compiled and installed python with ./configure --prefix=/opt/pyhon2.6.4... But I have to move it to a different directory (the reason is very difficult but I must do this)... I started the interpreter from shell and I was surprised because It still worked and It changed the sys.prefix so it pointed to the correct place so the sys.path was correct.... The questions are: HOW? Is it a feature which is not documented (at least I couldn't find anything about it)?

>From the official python documentation (http://docs.python.org/library/sys.html?highlight=sys#sys.prefix):
"sys.prefix¶

    A string giving the site-specific directory prefix where the platform independent Python files are installed; by default, this is the string '/usr/local'. This can be set at build time with the --prefix argument to the configure script. The main collection of Python library modules is installed in the directory prefix + '/lib/pythonversion' while the platform independent header files (all except pyconfig.h) are stored in prefix + '/include/pythonversion', where version is equal to version[:3]."

In my case, this is not correct: it looks, after I call the interpreter, something change the sys.prefix variable and point it to the right place and not to that directory which I used with the configuration script... This is very useful (I am happy because it solves one of my problems) but I am afraid of it will be do it in a different way in the future (as it is not documented).

Thanks,
Regards,
Balazs



More information about the Python-list mailing list