471,336 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,336 software developers and data experts.

PYTHONPATH not working on Windows XP (?)

Hi,

I'm trying to add a personal folder to the path used by python in
searching for packages and modules. This folder, "C:\docs\utils" , has
some packages not yet ready for "site-packages".

First, I tried sys.path.append("C:\docs\utils") BUT this only lasts
for the current python session.

Then, I read about PYTHONPATH and went to Control Panel - System -
Advanced - Enviromental Variables, and created a new variable
(PYTHONPATH) containing the folder. However, sys.path does not detects
it.. keeps printing the same old files:
>>import sys; import pprint; pprint.pprint(sys.path)
['C:\\Program Files\\AutoHotkey',
'C:\\Program Files\\Python25\\Lib\\idlelib',
'C:\\WINDOWS\\system32\\python25.zip',
'C:\\Program Files\\Python25\\DLLs',
'C:\\Program Files\\Python25\\lib',
'C:\\Program Files\\Python25\\lib\\plat-win',
'C:\\Program Files\\Python25\\lib\\lib-tk',
'C:\\Program Files\\Python25',
'C:\\Program Files\\Python25\\lib\\site-packages']

(By the way, how did that AutoHotkey folder got there? Can I remove it
from sys.path?)

After my second failure, I went to the registry
HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.5\ PythonPath

and added my folder there. Still nothing on sys.path , and my imports fail.

Any suggestions for adding my path to sys.path permanently? I'm
running out of ideas

Thanks,
Sergio
Sep 3 '07 #1
2 4106
Hi,
Any suggestions for adding my path to sys.path permanently?
You can write a file in Lib/site-packages with a 'pth' extension (the
name itself doesn't matter) containing the path you want to add.

Example:
MyCustomLib.pth:
C:/docs/utils

And be careful with path separator on win32. It should be "/" or "\\",
never "\".

Regards,

Olivier
Sep 3 '07 #2
Thanks!

It worked straightforward, and it's easier than messing with the
enviromental variables or the registry.

BTW, I'm still wondering how did Autohotkey got included in sys.path
(there are no other .pht files on my PC)

Regards,
Sergio

On 9/3/07, olivier <ol***********@gmail.comwrote:
Hi,
Any suggestions for adding my path to sys.path permanently?

You can write a file in Lib/site-packages with a 'pth' extension (the
name itself doesn't matter) containing the path you want to add.

Example:
MyCustomLib.pth:
C:/docs/utils

And be careful with path separator on win32. It should be "/" or "\\",
never "\".

Regards,

Olivier
--
http://mail.python.org/mailman/listinfo/python-list
Sep 3 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Rami A. Kishek | last post: by
4 posts views Thread by r.e.s. | last post: by
8 posts views Thread by Tero Pihlajakoski | last post: by
3 posts views Thread by Dr. Pastor | last post: by
10 posts views Thread by sushant.sirsikar | last post: by
reply views Thread by Michael Yanowitz | last post: by
8 posts views Thread by Stef Mientki | last post: by
5 posts views Thread by godsgift | last post: by
1 post views Thread by Aljosa Mohorovic | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.