Adding paths to sys.path permanently, and another problem...
Brian van den Broek
bvande at po-box.mcgill.ca
Fri Dec 17 02:36:32 CET 2004
Jeff Shannon said unto the world upon 2004-12-16 17:54:
> Amir Dekel wrote:
>> 2. os.path.expanduser("~") always gives me "C:\\" instead of my
>> homepath. I have tried to change my homepath in WinXP using set
>> homepath(in command line), and alsaw using the "Environment Variables"
>> in WinXP system properties, non helped. I really have to fix this
> Well, according to os.path.expanduser()'s docstring, it uses the $HOME
> environment variable to determine how to expand ~. I don't know what's
> standard on Windows, but I tried checking for a $HOME and found none.
> Here's (a slightly redacted copy of) what I *do* find (Win2K):
> Judging from this, I think that os.environ['USERPROFILE'] seems like it
> may do what you want, though os.environ['APPDATA'] might be useful as
> well. Of course, if you're trying to get something to work
> cross-platform, things may be more difficult -- but that's because
> Windows doesn't normally use ~ so its use is not supported very well.
> You may be able to create a $HOME that's equivalent to $USERPROFILE...
> Jeff Shannon
> Credit International
some 'nix-world tool (probably xemacs) that I put on my WinMe box didn't
like the lack of a HOME environment variable, either. This was easily
solved by adding the line
to my autoexec.bat file. (I don't know if this works in more recent
versions of Windows, but I'd imagine so.) There to, I have added a line
Which puts those dirs into sys.path (at the front, I believe). I also
used the .pth file trick because they two means differ as to where in
the sys.path they add their entries.
Best to all,
More information about the Python-list