【问题标题】:Python/Django shell won't startPython/Django shell 无法启动
【发布时间】:2023-04-07 13:39:01
【问题描述】:

Django 的一大特色是您可以打开一个 Python 解释器设置以用于您的项目。这可用于分析数据库中的对象,并允许在您的项目上执行任何 python 命令。我发现它对 Django 开发至关重要。使用以下命令在项目目录中调用它:

$ python manage.py shell

我刚刚开始开发一个新项目,但由于某种原因外壳无法正常工作。我在网上查看了错误并没有找到任何东西。对于此错误,我将不胜感激:


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'

提前感谢您的帮助!

【问题讨论】:

  • 你安装了 ipython 吗?它在您的PYTHONPATH 中吗?
  • 哦,太好了,那么django和ipython集成了吗?
  • @shylent,是的,从某种意义上说,如果安装了 IPython,它将使用 IPython 作为 shell。

标签:
python
django
shell