[IPython-user] startup home or working directory question on WinXP
Fernando Perez
Fernando.Perez at colorado.edu
Thu May 5 13:25:43 CDT 2005
D Brown wrote:
> I have had problems on differnt Win machines with ipython
> instalation complaining about it's home directory. Our
> systems have some sort of automount of a network drive
> during login. It seems that this is being set as some kind
> of "home" directory. I think ipython tries to use this
> mapped drive (H:) during startup and possibly for init
> files and it somtimes fails since it is not always
> available. I believe the actual ipython install location
> is in the C:\python23 directory and the installer seems to
> find the python installation. It's when ipython takes over
> that the problem shows up.
>
> Every time I start ipython I get this message:
>
> **********************************************************************
> Welcome to IPython. I will try to create a personal
> configuration directory
> where you can customize many aspects of IPython's
> functionality in:
>
> H:\_ipython
> WARNING:
>
> There was a problem with the installation:
> [Errno 2] No such file or directory: 'H:\\_ipython'
> Try to correct it or contact the developers if you think
> it's a bug.
> IPython will proceed with builtin defaults.
> Please press <RETURN> to start IPython.
>
>
> ********************************************
>
> Can anyone explain what ipython might be doing here and if
> there is a way to explicitly set the startup path? Where
> do ipython init files normally go? Any general hints on
> what Windows is doing would also be helpful. I realize
> this is an issue with my local setup but others might run
> across this occasionally.
Yes, IPython tries hard to figure out what 'home' means for a user, via the
following in IPython.genutils:
def get_home_dir():
"""Return the closest possible equivalent to a 'home' directory.
We first try $HOME. Absent that, on NT it's $HOMEDRIVE\$HOMEPATH.
Currently only Posix and NT are implemented, a HomeDirError exception is
raised for all other OSes. """ #'
try:
return os.environ['HOME']
except KeyError:
if os.name == 'posix':
raise HomeDirError,'undefined $HOME, IPython can not proceed.'
elif os.name == 'nt':
# For some strange reason, win9x returns 'nt' for os.name.
try:
return
os.path.join(os.environ['HOMEDRIVE'],os.environ['HOMEPATH'])
except:
try:
# Use the registry to get the 'My Documents' folder.
import _winreg as wreg
key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
homedir = wreg.QueryValueEx(key,'Personal')[0]
key.Close()
return homedir
except:
return 'C:\\'
elif os.name == 'dos':
# Desperate, may do absurd things in classic MacOS. May work
under DOS.
return 'C:\\'
else:
raise HomeDirError,'support for your operating system not
implemented.'
Since the very first thing it tries is to look for a HOME environment
variable, you may just define that to something sensible (and not
network-dependent), and IPython will reliably return that always.
I hope this helps,
f
More information about the IPython-user
mailing list