8
votes

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()
    
3
How did you install Python? That's not the standard directory python is installed in. - snapshoe
@ma3 : I didn't install Python, with Mac, Python is pre-installed. - prosseek
Ok, you're using the OS's python 2.6. How did you install IPython? I have OSX 10.6.5, Python 2.6, IPython 0.10.1, and my __init__.py file is very different from yours. Yours looks like it might be from an IPython 0.11 branch. - snapshoe
@ma3 : Well, just download the source, and run 'python setup.py install'. - prosseek
The source for 0.10.1? or for the 0.11 branch that's still in development and isn't complete yet? Why not simply easy_install ipython? That will get you 0.10.1, the most current stable version. - snapshoe

3 Answers

7
votes

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.

3
votes

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 
1
votes

For IPython 0.11.dev is fix that:

from IPython.frontend.terminal.ipapp import IPythonApp
app = IPythonApp(argv=[])
app.start()