IPython 找不到 Shell.IPShell 类

发布于 2024-10-04 02:10:41 字数 1492 浏览 5 评论 0原文

安装 Django 后,我按照教程使用 API。当我运行以下命令时。

python manage.py shell

我收到此错误消息。

  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'

我检查了其中是否有 Shell.py 模块和 IPShell 类。

/Library/Python/2.6/site-packages/IPython/Shell.py

class IPShell:
    """Create an IPython instance."""

这有什么问题?我的IPython/Python/操作系统如下。

  • Mac OS X 10.6.5
  • Python 2.6.1
  • IPython 版本 0.10.1

添加

>>> import IPython
>>> IPython.Shell
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'module' object has no attribute 'Shell'
>>> print IPython.__file__
/Library/Python/2.6/site-packages/IPython/__init__.py

已解决

在 ma3 和 Ignacio 的帮助下,我可以解决这个问题。

  1. 删除 site-package/IPython 和 site-package/ipython*.egg
  2. sudo easy_install ipython 以全新安装 IPython
  3. 将补丁应用到 Ignacio 链接的 django 的 shell.py。

    <前><代码>尝试: shell = IPython.InteractiveShell() 除了属性错误: # IPython < 0.11 # 显式传递一个空列表作为参数,否则 IPython # 将使用此脚本中的 sys.argv。 shell = IPython.Shell.IPShell(argv=[]) shell.mainloop()

After installing Django, I followed the tutorial Playing with the API. When I run the following command.

python manage.py shell

I got this error message.

  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'

I checked that I have Shell.py module, and IPShell class inside it.

/Library/Python/2.6/site-packages/IPython/Shell.py

class IPShell:
    """Create an IPython instance."""

What's wrong with this? My IPython/Python/OS is as follows.

  • Mac OS X 10.6.5
  • Python 2.6.1
  • IPython version 0.10.1

ADDED

>>> import IPython
>>> IPython.Shell
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'module' object has no attribute 'Shell'
>>> print IPython.__file__
/Library/Python/2.6/site-packages/IPython/__init__.py

SOLVED

With ma3 and Ignacio's help, I could solve this issue.

  1. Remove site-package/IPython and site-package/ipython*.egg
  2. sudo easy_install ipython to fresh install the IPython
  3. Apply the patch to the django's shell.py as Ignacio linked.

        try:
            shell = IPython.InteractiveShell()
        except AttributeError:
            # IPython < 0.11
            # Explicitly pass an empty list as arguments, because otherwise IPython
            # would use sys.argv from this script.
            shell = IPython.Shell.IPShell(argv=[])
        shell.mainloop()
    

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

流心雨 2024-10-11 02:10:41

早在 2009 年 8 月 19 日,IPython 就进行了更改,删除了这个名字,Django 还没有跟上。所以,Django 错误。

编辑:

这里

A change was made to IPython back in August 19, 2009 that removed this name, and Django hasn't caught up yet. So, Django bug.

EDIT:

And here it is.

嘦怹 2024-10-11 02:10:41

以下是 GitHub 上 django-extensions 存储库的官方提交:

Django-Extensions GitHub 存储库< /a>

您可以通过执行以下操作来安装它:

$ git clone git://github.com/django-extensions/django-extensions.git
$ cd django-extensions
$ python setup.py install 

Here is an official commit from django-extensions repo at GitHub:

Django-Extensions GitHub repo

You can install it by doing this:

$ git clone git://github.com/django-extensions/django-extensions.git
$ cd django-extensions
$ python setup.py install 
游魂 2024-10-11 02:10:41

对于 IPython 0.11.dev 修复:

from IPython.frontend.terminal.ipapp import IPythonApp
app = IPythonApp(argv=[])
app.start()

For IPython 0.11.dev is fix that:

from IPython.frontend.terminal.ipapp import IPythonApp
app = IPythonApp(argv=[])
app.start()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文