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.
>>> 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
With ma3 and Ignacio's help, I could solve this issue.
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With