【问题标题】:AttributeError: 'module' object has no attribute 'Shell' for ipythonAttributeError: 'module' 对象没有 ipython 的属性 'Shell'
【发布时间】:2014-04-17 10:52:23
【问题描述】:

我已经在虚拟环境中的机器上安装了 ipython,如下所示

pip install ipython

Downloading/unpacking ipython
  Downloading ipython-2.0.0.tar.gz (11.9MB): 11.9MB downloaded
  Running setup.py egg_info for package ipython

Installing collected packages: ipython
  Running setup.py install for ipython
    checking package data

    Installing ipengine2 script to /home/user/.virtualenvs/project/bin
    Installing iptest script to /home/user/.virtualenvs/project/bin
    Installing ipython2 script to /home/user/.virtualenvs/project/bin
    Installing ipcluster2 script to /home/user/.virtualenvs/project/bin
    Installing ipcluster script to /home/user/.virtualenvs/project/bin
    Installing ipython script to /home/user/.virtualenvs/project/bin
    Installing ipcontroller2 script to /home/user/.virtualenvs/project/bin
    Installing ipcontroller script to /home/user/.virtualenvs/project/bin
    Installing iptest2 script to /home/user/.virtualenvs/project/bin
    Installing ipengine script to /home/user/.virtualenvs/project/bin
Successfully installed ipython
Cleaning up...

所以当我从 virtualenv 内部以 python manage.py shell 启动我的 shell 时,我看到以下错误

Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_manager(settings)
  File "/home/user/.virtualenvs/project/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/home/user/.virtualenvs/project/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/user/.virtualenvs/project/local/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/user/.virtualenvs/project/local/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/home/user/.virtualenvs/project/local/lib/python2.7/site-packages/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "/home/user/.virtualenvs/project/local/lib/python2.7/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'

Django 版本 - 1.2.3 venv 内的 ipython 版本 - 2.0.0

那么为什么会出现以及如何避免,我以前没有经历过这种情况

【问题讨论】:

    标签: python django shell virtualenv


    【解决方案1】:

    我遇到了同样的问题。我通过将 Django 升级到 1.2.7 解决了这个问题。

    pip install --upgrade django==1.2.7
    

    如果不可行,您可以尝试安装旧版本的 IPython,但我还没有测试过是否可行。

    【讨论】:

      猜你喜欢
      • 2021-01-15
      • 2015-05-16
      • 1970-01-01
      • 2022-12-20
      • 1970-01-01
      • 2018-01-14
      • 2014-08-15
      • 2016-07-17
      • 2015-05-26
      相关资源
      最近更新 更多