Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IPython doesn't find the Shell.IPShell class

After installing Django, I followed the tutorial Playing with the API. When I run the following command.

python manage.py shell

I got this error message.

  File "/Library/Python/2.6/site-packages/django/core/management/commands/shell.py", 
  line 29, in handle_noargs
    shell = IPython.Shell.IPShell(argv=[])
  AttributeError: 'module' object has no attribute 'Shell'

I checked that I have Shell.py module, and IPShell class inside it.

/Library/Python/2.6/site-packages/IPython/Shell.py

class IPShell:
    """Create an IPython instance."""

What's wrong with this? My IPython/Python/OS is as follows.

  • Mac OS X 10.6.5
  • Python 2.6.1
  • IPython version 0.10.1

ADDED

>>> import IPython
>>> IPython.Shell
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'module' object has no attribute 'Shell'
>>> print IPython.__file__
/Library/Python/2.6/site-packages/IPython/__init__.py

SOLVED

With ma3 and Ignacio's help, I could solve this issue.

  1. Remove site-package/IPython and site-package/ipython*.egg
  2. sudo easy_install ipython to fresh install the IPython
  3. Apply the patch to the django's shell.py as Ignacio linked.

        try:
            shell = IPython.InteractiveShell()
        except AttributeError:
            # IPython < 0.11
            # Explicitly pass an empty list as arguments, because otherwise IPython
            # would use sys.argv from this script.
            shell = IPython.Shell.IPShell(argv=[])
        shell.mainloop()
    
like image 316
prosseek Avatar asked Nov 24 '10 02:11

prosseek


3 Answers

A change was made to IPython back in August 19, 2009 that removed this name, and Django hasn't caught up yet. So, Django bug.

EDIT:

And here it is.

like image 196
Ignacio Vazquez-Abrams Avatar answered Nov 03 '22 10:11

Ignacio Vazquez-Abrams


Here is an official commit from django-extensions repo at GitHub:

Django-Extensions GitHub repo

You can install it by doing this:

$ git clone git://github.com/django-extensions/django-extensions.git
$ cd django-extensions
$ python setup.py install 
like image 41
miki725 Avatar answered Nov 03 '22 11:11

miki725


For IPython 0.11.dev is fix that:

from IPython.frontend.terminal.ipapp import IPythonApp
app = IPythonApp(argv=[])
app.start()
like image 1
Peter Avatar answered Nov 03 '22 10:11

Peter