sys.path append problem

Gerhard Häring gerhard at bigfoot.de
Thu Mar 21 00:35:11 EST 2002


* hejduk <claxtonr at beer.com> [2002-03-20 21:08 -0800]:
> I've recently installed python 2.2.1 on my slak 8.0 linux computer. I
> want to do some gui programming with wxPython, but in order to do that
> I have to change the module search path (sys.path) to include the
> wxPython module. I've tried the following:
> 
> import sys
> sys.append('/some/new/dir')
> 
> This works, but when i shut Python down and restart it the Path has
> been reset to the default, meaning that it is impossible to run
> scripts that attempt to import modules from outside of this default
> path.

That's the way it's supposed to be. If you want to append to sys.path
for all programs that you start, you must either set the PYTHONPATH
environment variable, or, preferrably, put a sitecustomize.py file
somewhere in your PYTHONPATH or into one of the directories of sys.path.

Alternatively, you can create a .pth file in the site-packages
directory.

> When I used python on windoze the sys.path saved when I appended to
> it, so I'm assuming that this is what is suppossed to happen.

Really? That would be news to me.

> I realize that there are several work arounds to this problem, but I
> would prefer to correct it rather than cheat around it, because it
> could be just a symptom of a larger problem.
> 

> Anyone know what the problem is?

You didn't install wxPython with "python setup.py install", did you? It
will then be installed into the site-packages directory and you don't
need to do customize anything.

Gerhard
-- 
mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
web:    http://www.cs.fhm.edu/~ifw00065/    OpenPGP public key id AD24C930
public key fingerprint: 3FCC 8700 3012 0A9E B0C9  3667 814B 9CAA AD24 C930
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))




More information about the Python-list mailing list