Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

frozen setup: permission denied for default ipython_dir #2702

Closed
eudoxos opened this Issue · 11 comments

4 participants

@eudoxos

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
Owner

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

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
Owner

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
Owner

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
Owner

@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
Owner

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

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
@minrk
Owner

@takluyver did you come up with anything here?

@takluyver
Owner

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
Owner

Okay, will remove the special case, then.

@minrk minrk referenced this issue from a commit in minrk/ipython
@minrk minrk remove special-case in get_home_dir for frozen dists
closes #2702
27a741f
@Carreau Carreau closed this in #3677
@mattvonrocketstein mattvonrocketstein referenced this issue from a commit in mattvonrocketstein/ipython
@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.