By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,995 Members | 1,217 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,995 IT Pros & Developers. It's quick & easy.

PATH env var precedences for module load on windows

P: 16
with a windows port of a pygtk, I've had some users having problems with the app loading some system-wide gtk dll they have on their system for whatever reason instead of the ones I've bundled with the program.
I though I could make python search the apps bin directory before the other ones by prepending the corresponding path to the other ones in the PATH environment variable:
Expand|Select|Wrap|Line Numbers
  1. os.environ['PATH']=os.path.join(basedir,'gtklib','bin')+';'+os.environ['PATH']
but this does not appear to work - if a place a file, called the same way as a dll in the gtklib/bin dir, with some garbage in it in %WINDIR%\system32, python attempts to load that one (failing to do so clearly).

Does any one know how I can ensure my bin dir getting scanned before any other dirs?

Mar 6 '11 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 2.5K+
P: 2,851
Try this:
Expand|Select|Wrap|Line Numbers
  1. import sys
  2. sys.path.insert(path_to_search_first, 0)
Mar 6 '11 #2

P: 16
Thanks for your reply, unfortunately this does not work either. After further investigation I found - from which I deduce that it's basically impossible to search before the system32 dir unless you put the dlls in the same folder as the executable... very ugly.
Mar 7 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.