How to extend sys.path on Win9x permanently?
Mark Pilgrim
f8dy at my-deja.com
Tue Jan 30 13:45:04 EST 2001
In article <3A7671A2.30478E8C at engcorp.com>,
Peter Hansen <peter at engcorp.com> wrote:
> Martin Bless wrote:
> >
> > Python20, Win98, PythonWin
> >
> > (1) I'd like Python.exe/DOS AND Python in PythonWin to start
> > up with an extended sys.path, having my own lib added, as if a
> > sys.path.append('c:\\mylib') had already been performed.
> > How can I add the extra path permanently?
>
> Note certain, but it's likely that site.py is imported even under
> PythonWin. If that's true, and it should be easy to test, just
> create a file in your Python directory with an extension .PTH,
> and place within it the name of the directory you want added
> to sys.path.
Just confirmed that this does work under PythonWin (at least ActiveState's
port).
Step-by-step instructions for Windows: - Find your base Python directory.
The default is C:\Python20. - In this directory, create a new text file
called something like "my.pth". Name doesn't matter, but the ".pth"
extension does. - In this file, enter the full path of your scripts
directory, e.g. c:\mylib. If you have more than one, list them each on their
own line. Do *not* use double-backslashes ("c:\\mylib" is wrong); this is
not a Python string, it's just a text file. (I made this mistake. ;-) - Quit
and re-run PythonWin. "import sys; print '\n'.join(sys.path)" to make sure
your directory is listed.
-M
--
You're smart; why haven't you learned Python yet? http://diveintopython.org/
Sent via Deja.com
http://www.deja.com/
More information about the Python-list
mailing list