PYTHONPATH or any other way to set seachpath (winXP) ?

Jussi Salmela tiedon_jano at hotmail.com
Sun Feb 4 05:31:01 EST 2007


Stef Mientki kirjoitti:
> Is it possible to change the searchpath for modules on the flight,
> under winXP ?
What do you mean by *on the flight*: inside IDLE? using the command line?
> Most preferred is some command to extend the searchpath.
> (the environment variable PYTHONPATH needs a reboot)
> 
No, it doesn't. PYTHONPATH can be updated somewhere in the environment 
options (sorry: I've got a Finnish language XP version, so I don't 
remember the exact terms) and the new path comes in effect immediately 
i.e. the launches after that see the new definition.

That way of changing the PYTHONPATH is a little difficult, though. In 
command line usage i.e. CMD.EXE I have been using these kinds of bat 
files to alternate between versions 2.4 and 2.5 of Python. (These were 
suggested earlier by someone in this group I think):
===
Py24.bat (Py25.bat has Python25 instead of Python24 in it)
===
@echo off
if .%1.==.. goto NODEV
set DEMOHOME=%1
goto CONT
:NODEV
set DEMOHOME=C:
:CONT
set PYTHONHOME=%DEMOHOME%\Python24
set PYTHONPATH=%PYTHONHOME%;
set PYTHON=%PYTHONHOME%\python.exe
set PYTHONW=%PYTHONHOME%\pythonw.exe
set PATH=%PYTHONHOME%;%PATH%

===
Py.bat (to launch Python)
===
"%PYTHON%" "%1.py" "%2" "%3" "%4" "%5" "%6" "%7" "%8" "%9"

> thanks,
> Stef Mientki

HTH,
Jussi



More information about the Python-list mailing list