Modify Python Path

Gerhard Häring gerhard.haering at gmx.de
Sat Dec 7 15:13:20 EST 2002


* Kenneth Gomez <kennethg at pd.jaring.my> [2002-12-07 20:05 +0000]:
> Hello,
> 
> This may seem like a silly question but I have tried the documentation
> and the system registry but I cant find where Python stores the search
> path.
> 
> I am using poor old Win Me.
> 
> I have modified the path setting under
> HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.2\PythonPath to add in
> my path : c:\test
> 
> but, Python still cant find the modules that I have saved in the test
> directory.
> 
> Could you kindly advise me where to make the necessary changes?

*Not* in the registry.

Either set an environment variable called PYTHONPATH that includes your
directories, like:

    SET PYTHONPATH=c:\test;c:\mylibs

In your home user version of Windows, you might still have to use the
\AUTOEXEC.BAT file to make this persistent. So option #2 might be a
better one:

Alternatively, create a .pth file in your site-packages directory
(c:\python22\lib\site-packages in the default installation). Call it
whatever you like, for example mypkg.pth. In this file, put *one line*
with the directory you want to have in your Python module search path.
For example:

    c:\test

HTH,

-- Gerhard




More information about the Python-list mailing list