开发者

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()
    


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.


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 


For IPython 0.11.dev is fix that:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜