473,466 Members | 1,286 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 4193
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Rami A. Kishek | last post by:
Hi, I would really appreciate help on this from all ye Win-oriented people. I have been using python under Linux for quite a while, know little about windows. I just upgraded my Python on WinME...
4
by: r.e.s. | last post by:
I have no PYTHONPATH nor any other python-related environment variables, yet everything seems fine. (I'm using PythonWin with winxp.) As long as modules are loaded through PythonWin, is...
8
by: Tero Pihlajakoski | last post by:
Hi, I've been experimenting on embedding Python to a C software, and ran into a little problem with PYTHONPATH (I'm running on linux). Here's the deal: When trying to call...
3
by: Dr. Pastor | last post by:
Several Documents about Python refer to PYTHONPATH. I could not find such variable. (Python 2.4.2, IDLE 1.1.2, Windows XP) How should/could I nominate a Directory to be the local Directory?...
10
by: sushant.sirsikar | last post by:
Hi, I am using Linux env.I set the PYTHONPATH using import sys sys.path.append(----) But we i close python and start again i is not showing my new entry in PYTHONPATH. Can anyone help me to...
0
by: Michael Yanowitz | last post by:
Hello: Someone on my team tried out installing my Python code and found that setting PYTHONPATH does not work, but setting PATH environment variable works the way PYTHONPATH should. Is that how...
8
by: Stef Mientki | last post by:
hello, after cleaning up a PC, Python can't find any libraries anymore. But happily I've still one PC, where Python is running perfect. Now I always read about the environment variable...
5
by: godsgift | last post by:
Dear All iam using Windows XP,i want to set two path in pythonpath in environment Variable ,now my problem is If iam setting two path in environment variable,my second path is not...
1
by: Aljosa Mohorovic | last post by:
i have a working MySQLdb module (/usr/lib/python2.4/site-packages/ MySQL_python-1.2.2-py2.4-linux-i686.egg), using it without problems. "clean shell" after login: python -c "import MySQLdb"...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.