Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

will not run within PIL build directory #2580

Closed
ghost opened this issue Nov 15, 2012 · 7 comments
Closed

will not run within PIL build directory #2580

ghost opened this issue Nov 15, 2012 · 7 comments
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Nov 15, 2012

ipython will not start from within PIL build dir for me:
steps to reproduce

virtualenv myenv
pip install PIL --no-install
cd myenv/build/PIL
ipython
(bang, traceback below)
cd ..
ipython
(everything is fine)

traceback

Traceback (most recent call last):
  File "/home/user/.virtualenvs/project/bin/ipython", line 9, in <module>
    load_entry_point('ipython==0.13.1', 'console_scripts', 'ipython')()
  File "/home/user/.virtualenvs/projectlib/python2.6/site-packages/IPython/frontend/terminal/ipapp.py", line 388, in launch_new_instance
    app.initialize()
  File "<string>", line 2, in initialize
  File "/home/user/.virtualenvs/project/lib/python2.6/site-packages/IPython/config/application.py", line 84, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/user/.virtualenvs/project/lib/python2.6/site-packages/IPython/frontend/terminal/ipapp.py", line 324, in initialize
    self.init_shell()
  File "/home/user/.virtualenvs/project/lib/python2.6/site-packages/IPython/frontend/terminal/ipapp.py", line 340, in init_shell
    ipython_dir=self.ipython_dir)
  File "/home/user/.virtualenvs/project/lib/python2.6/site-packages/IPython/config/configurable.py", line 318, in instance
    inst = cls(*args, **kwargs)
  File "/home/user/.virtualenvs/project/lib/python2.6/site-packages/IPython/frontend/terminal/interactiveshell.py", line 360, in __init__
    user_module=user_module, custom_exceptions=custom_exceptions
  File "/home/user/.virtualenvs/project/lib/python2.6/site-packages/IPython/core/interactiveshell.py", line 476, in __init__
    self.init_reload_doctest()
  File "/home/user/.virtualenvs/project/lib/python2.6/site-packages/IPython/core/interactiveshell.py", line 666, in init_reload_doctest
    doctest_reload()
  File "/home/user/.virtualenvs/project/lib/python2.6/site-packages/IPython/utils/doctestreload.py", line 74, in doctest_reload
    doctest.DocTestRunner.run = dhook_wrap(doctest.DocTestRunner.run)
AttributeError: 'module' object has no attribute 'DocTestRunner'

@Carreau
Copy link
Member

Carreau commented Nov 15, 2012

Short. From my phone.

What is the content of the cwd?
Does it have any folder that are module (doctest for example?) and that
would be imported in place of python/ipython ones because of conflicting
name ?

If this is the case there is nothing we can do.
Le 15 nov. 2012 10:45, "Bartek" notifications@github.com a écrit :

ipython will not start from within PIL build dir for me:
my (slightly) steps to reproduce

virtualenv myenv
pip install PIL --no-install
cd myenv/build/PIL
ipython
(bang, traceback below)
cd ..
ipython
(everything is fine)

traceback

Traceback (most recent call last):
File "/home/bartek/.virtualenvs/pko/bin/ipython", line 9, in
load_entry_point('ipython==0.13.1', 'console_scripts', 'ipython')()
File "/home/bartek/.virtualenvs/pko/lib/python2.6/site-packages/IPython/frontend/terminal/ipapp.py", line 388, in launch_new_instance
app.initialize()
File "", line 2, in initialize
File "/home/bartek/.virtualenvs/pko/lib/python2.6/site-packages/IPython/config/application.py", line 84, in catch_config_error
return method(app, _args, *_kwargs)
File "/home/bartek/.virtualenvs/pko/lib/python2.6/site-packages/IPython/frontend/terminal/ipapp.py", line 324, in initialize
self.init_shell()
File "/home/bartek/.virtualenvs/pko/lib/python2.6/site-packages/IPython/frontend/terminal/ipapp.py", line 340, in init_shell
ipython_dir=self.ipython_dir)
File "/home/bartek/.virtualenvs/pko/lib/python2.6/site-packages/IPython/config/configurable.py", line 318, in instance
inst = cls(_args, *_kwargs)
File "/home/bartek/.virtualenvs/pko/lib/python2.6/site-packages/IPython/frontend/terminal/interactiveshell.py", line 360, in init
user_module=user_module, custom_exceptions=custom_exceptions
File "/home/bartek/.virtualenvs/pko/lib/python2.6/site-packages/IPython/core/interactiveshell.py", line 476, in init
self.init_reload_doctest()
File "/home/bartek/.virtualenvs/pko/lib/python2.6/site-packages/IPython/core/interactiveshell.py", line 666, in init_reload_doctest
doctest_reload()
File "/home/bartek/.virtualenvs/pko/lib/python2.6/site-packages/IPython/utils/doctestreload.py", line 74, in doctest_reload
doctest.DocTestRunner.run = dhook_wrap(doctest.DocTestRunner.run)
AttributeError: 'module' object has no attribute 'DocTestRunner'


Reply to this email directly or view it on GitHubhttps://github.com//issues/2580.

@takluyver
Copy link
Member

There's a doctest.py file there. It looks like we're adding the cwd to sys.path in IPython.core.shellapp.InteractiveShellApp.init_path, which is called before IPython.utils.doctestreload.doctest_reload, which tries to load doctest.

I think the simplest fix would be to import doctest at the main import time, but I'm not quite clear why it's being imported inside a function at present. doctestreload looks like older code, so perhaps @fperez can shed some light on it?

@bfroehle
Copy link
Contributor

The current directory when IPython is started will already be in sys.path --- Python does this automatically.

init_path only adds '' which is the current directory (which would change if you run %cd <dir> in IPython). So importing doctest earlier won't actually fix this bug. In fact, the bug is essentially unavoidable.

See also #2578.

@takluyver
Copy link
Member

Python automatically adds the directory where the script is located to sys.path, but I don't think it automatically adds the working directory. If you pick a name that's imported at the normal time, like re, and make re.py in the working directory, it doesn't cause a problem for IPython.

The >>> interactive shell does add the working directory, and I think init_path is us mimicking that.

@bfroehle
Copy link
Contributor

Yes, correct. So I guess we just close this issue. Sorry.. misread that. Reopening.

@bfroehle bfroehle reopened this Nov 19, 2012
@takluyver
Copy link
Member

Marked as bug, low priority (because there's an easy workaround)

@takluyver
Copy link
Member

We no longer try to load doctest at all, so this isn't a problem now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants