Django_extensions无法使用iPython笔记本

时间:2013-05-13 04:54:45

标签: django virtualenv ipython-notebook django-extensions

我正在使用Django 1.4.5,刚刚在virtualenv中安装了django-extensions。我使用的是Python 2.7.1。当我输入:

./manage.py shell_plus --notebook

我收到错误:

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/.../lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/Users/.../lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/.../lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/.../lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/Users/.../lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
    return self.handle_noargs(**options)
  File "/Users/.../lib/python2.7/site-packages/django_extensions/management/commands/shell_plus.py", line 140, in handle_noargs
    run_notebook()
  File "/Users/.../lib/python2.7/site-packages/django_extensions/management/commands/shell_plus.py", line 71, in run_notebook
    from IPython.frontend.html.notebook import notebookapp
ImportError: No module named IPython.frontend.html.notebook

没有--notebook选项,它可以正常工作。此外,ipython notebook也可以。

有人可以建议可能出现的问题吗?

谢谢!

2 个答案:

答案 0 :(得分:1)

我通过使用新的virtualenv解决了这个问题,并确保我已经安装了iPython,即:

pip install tornado
pip install pyzmq
pip install ipython
./manage.py shell_plus --notebook

答案 1 :(得分:0)

除了上面提到的用户[https://stackoverflow.com/users/905720/racing-tadpole](赛车蝌蚪)之外,我还必须安装jinja2。

pip install jinja2

测试ipython笔记本上的django shell_plus缺少的方法是单独执行ipython笔记本。这样我就可以检测到所有丢失的库,比如jinja2。

ipython notebook

如果这样可行,那么shell_plus --notebook也很有用。