簡體   English   中英

Python / Django shell無法啟動

[英]Python/Django shell won't start

Django的一個重要特性是你可以打開一個python解釋器設置,用於你的項目。 這可用於分析數據庫中的對象,並允許在項目上執行任何python命令。 我發現Django開發很重要。 使用以下命令在項目目錄中調用它:

$ python manage.py shell

我剛開始開發一個新項目,由於某種原因,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以某種方式錯誤地安裝。 嘗試使用以下命令啟動shell:

./manage.py shell --plain

啟動標准的Python shell,而不是IPython。 如果可行,那么嘗試完全刪除IPython並重新安裝它。

IPython 0.11有一個不同的API,在最后的Django版本中存在修復。

對於較舊的Django版本,您可以使用IPython 0.10,它可以工作:

pip install ipython==0.10

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM