Skip to content

frozen setup: permission denied for default ipython_dir #2702

Closed
eudoxos opened this Issue Dec 18, 2012 · 11 comments

4 participants

@eudoxos
eudoxos commented Dec 18, 2012

Ipython's embedded shell is creating its configuration directory in ../.ipython in frozen setups. When the directory is not writeable (such as if the frozen code was in c:/Program\ Files/app/, then c:/Program\ Files/.ipython fails to be created by non-admin), ipython fails with WindowsError. This case should be handled more gracefully - e.g. by doing without configuration directory.

A workaround is to set IPYTHONDIR to something writeable (in my case, expanduser('~/.ipython')) before constructing the embedded shell.

@takluyver
IPython member

Thanks for the report. Can you provide quick instructions to repeat this? In particular, which freezing tool are you using? And can you track down the code that picks that directory?

@eudoxos
eudoxos commented Dec 21, 2012

I am using www.pyinstaller.org for the freeze. The code in woo.qt which causes the problem is

from IPython.frontend.terminal.embed import InteractiveShellEmbed
from IPython.config.configurable import MultipleInstanceError
try: InteractiveShellEmbed.instance() 
except MultipleInstanceError: print 'Already in ipython, not embedding new instance'

The traceback is as follows:

C:\Program Files (x86)\Woo> wwoo.exe
[....]
Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "c:\src\woo\build\pyi.win32\woo.pyinstaller\out00-PYZ.pyz\wooMain", line 231, in main
  File "c:\src\pyinstaller-develop\PyInstaller\loader\pyi_iu.py", line 386, in importHook
  File "c:\src\pyinstaller-develop\PyInstaller\loader\pyi_iu.py", line 480, in doimport
  File "c:\src\woo\build\pyi.win32\woo.pyinstaller\out00-PYZ.pyz\woo.qt", line 64, in <module>
  File "c:\src\woo\build\pyi.win32\woo.pyinstaller\out00-PYZ.pyz\IPython.config.configurable", line 318, in instance
  File "c:\src\woo\build\pyi.win32\woo.pyinstaller\out00-PYZ.pyz\IPython.frontend.terminal.embed", line 97, in __init__
  File "c:\src\woo\build\pyi.win32\woo.pyinstaller\out00-PYZ.pyz\IPython.frontend.terminal.interactiveshell", line 360, in __init__
  File "c:\src\woo\build\pyi.win32\woo.pyinstaller\out00-PYZ.pyz\IPython.core.interactiveshell", line 412, in __init__
  File "c:\src\woo\build\pyi.win32\woo.pyinstaller\out00-PYZ.pyz\IPython.core.interactiveshell", line 522, in init_ipython_dir
  File "c:\src\woo\build\pyi.win32\woo.pyinstaller\out00-PYZ.pyz\IPython.utils.traitlets", line 307, in __set__
  File "c:\src\woo\build\pyi.win32\woo.pyinstaller\out00-PYZ.pyz\IPython.utils.traitlets", line 456, in _notify_trait
  File "c:\src\woo\build\pyi.win32\woo.pyinstaller\out00-PYZ.pyz\IPython.core.interactiveshell", line 496, in _ipython_dir_changed
  File "c:\src\woo\build\pyi.win32\woo.pyinstaller\out00-PYZ.pyz\os", line 157, in makedirs
WindowsError: [Error 5] Access is denied: u'c:\\Program Files (x86)\\.ipython'
@takluyver
IPython member

It looks like the relevant code is here: https://github.com/ipython/ipython/blob/master/IPython/utils/path.py#L172

It seems to be doing that deliberately, although I'm not sure why. @fperez , @ellisonbg , @minrk : does anyone remember why get_home_dir() has a special case for frozen executables?

@minrk
IPython member
minrk commented Jan 9, 2013

Nope - I've never understood that part. Anyone with better long-term memory?

If nobody can come up with a still-valid case for it, I say we remove it, and wait for it to come up again.

@bfroehle
@minrk
IPython member
minrk commented Jan 9, 2013

@bfroehle yes, I think we've moved VCS systems twice since that code came in. We've already found that several of the special cases that had crept into get_home_dir had become inappropriate, so I won't be surprised if this did as well.

@takluyver
IPython member

Ah, IpyKit rings a bell. It was a frozen copy of IPython for Windows users, from about 5 years ago. You can still download it. Digging into the source suggests that it's done like that so that it can use config files shipped in the package.

I do know someone who still freezes IPython, I'll just check with him whether he relies on this behaviour.

@eudoxos
eudoxos commented Jan 10, 2013

My wild guess is that there was conflation of frozen and portable (no-install, runnable from removable media without writing to other FS) setup.

@takluyver takluyver was assigned Jun 29, 2013
@minrk
IPython member
minrk commented Jul 17, 2013

@takluyver did you come up with anything here?

@takluyver
IPython member

Oh, yes, Almar (who freezes IPython for Pyzo) says he doesn't rely on this feature, so I think we can safely remove the special case for running frozen.

@minrk
IPython member
minrk commented Jul 17, 2013

Okay, will remove the special case, then.

@minrk minrk added a commit to minrk/ipython that referenced this issue Jul 17, 2013
@minrk minrk remove special-case in get_home_dir for frozen dists
closes #2702
27a741f
@Carreau Carreau closed this in #3677 Jul 18, 2013
@mattvonrocketstein mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
@minrk minrk remove special-case in get_home_dir for frozen dists
closes #2702
34b906d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.