473,248 Members | 1,557 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,248 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 4186
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: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...

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.