Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
using ipython in Slicer3 show how os.environ['HOME'] is not defined #154
Currently in genutils.py at line 942 in ipython 0.10 ipython gives up trying to find the home directory which causes ipython to fail to load.
At this point ipython could still try a little harder to find a home directory with something like the following:
import subprocess p = subprocess.Popen('echo $HOME',shell=True,stdout=subprocess.PIPE) potential_home = p.communicate().strip() if len(potential_home) > 0: return potential_home else: raise HomeDirError,'undefined $HOME, IPython can not proceed.'
This issue occurred on OS X 10.6.4, Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29), Slicer 3.6.1 rev 15021
Unfortunately the code you propose is posix-specific, and won't work on Windows. IPython is cross platform, so we need a platform-independent solution.
If you find one, by all means post it, the easiest way to have it merged is to make it as a pull request on github, but a patch on our -dev list or even here will be equally welcome.
Yes, you are correct my proposal is posix-specific. That's why it's within the block which checks if the OS is posix. Here is a patch:
--- genutils.py 2009-08-04 19:26:20.000000000 -0400 +++ genutils.py 2010-09-23 16:34:45.000000000 -0400 @@ -940,7 +940,13 @@ return homedir except KeyError: if os.name == 'posix': - raise HomeDirError,'undefined $HOME, IPython can not proceed.' + import subprocess + p = subprocess.Popen('echo $HOME',shell=True,stdout=subprocess.PIPE) + potential_home = p.communicate().strip() + if len(potential_home) > 0: + return potential_home + else: + raise HomeDirError,'undefined $HOME, IPython can not proceed.' elif os.name == 'nt': # For some strange reason, win9x returns 'nt' for os.name. try: