how to change sys.path?
Andrew Robert
andrew.arobert at gmail.com
Wed May 24 12:52:27 EDT 2006
Dennis Lee Bieber wrote:
> On Wed, 24 May 2006 14:45:55 GMT, John Salerno
> <johnjsal at NOSPAMgmail.com> declaimed the following in comp.lang.python:
>
>> I just right-clicked on My Computer --> Properties --> Advanced -->
>> Environment Variables, and added a new one called PYTHONPATH. I don't
>> know if that edits the registry, but you don't *manually* have to edit
>> the registry if you do it that way...unless of course you aren't
>> supposed to be doing it that way! But it worked anyway. :)
>
> I may have gotten slightly confused -- I had an impression that, at
> least one poster in the thread, wanted to do this from within a Python
> program. That does go into registry modifications.
>
> For example, look at the entries under:
>
> (system environment, I believe)
> HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
> Manager\Environment
>
> (user specific environment)
> HKEY_CURRENT_USER\Environment
>
> Though in the case of PYTHONPATH, the core value seems to be in (for
> my install)
>
> HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.3\PythonPath
>
> which also has subkeys for Pythonwin, win32, and win32com
>
Instead of messing with the registry, wouldn't it be easier to just add
a line similar to this within your code?
sys.path.append(r'\\mynetwork\share')
I use something similar so that all my scripts can locate the same
home-grown modules no matter where they are run from.
More information about the Python-list
mailing list