Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python/Django shell won't start

One of the great features of Django is that you can open a python interpreter set-up for use with your project. This can be used to analyse objects in a database and allows any python commands to be executed on your project. I find it essential for Django development. It is invoked in the project directory using this command:

$ python manage.py shell

I have just started developing a new project and for some reason the shell does not work. I have had a look online for the error and not found anything. I would greatly appreciate any help on this error:


Traceback (most recent call last):
  File "manage.py", line 11, in 
    execute_manager(settings)
  File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 362, in execute_manager
    utility.execute()
  File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 303, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 195, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 222, in execute
    output = self.handle(*args, **options)
  File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  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'

Thanks in advance for your help!

like image 335
danpalmer Avatar asked Jan 16 '10 16:01

danpalmer


2 Answers

It seems like IPython is installed wrongly somehow. Try starting the shell with:

./manage.py shell --plain

to start the standard Python shell, rather than IPython. If that works, then trying removing IPython completely and reinstalling it.

like image 167
Daniel Roseman Avatar answered Oct 01 '22 14:10

Daniel Roseman


IPython 0.11 has a different API, for which a fix exists in the last Django versions.

For older Django versions, you can use IPython 0.10, which does work:

pip install ipython==0.10
like image 34
vdboor Avatar answered Oct 01 '22 16:10

vdboor