IPython 找不到 Shell.IPShell 类
安装 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 的帮助下,我可以解决这个问题。
- 删除 site-package/IPython 和 site-package/ipython*.egg
- sudo easy_install ipython 以全新安装 IPython
将补丁应用到 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.
- Remove site-package/IPython and site-package/ipython*.egg
- sudo easy_install ipython to fresh install the IPython
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
早在 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.
以下是 GitHub 上 django-extensions 存储库的官方提交:
Django-Extensions GitHub 存储库< /a>
您可以通过执行以下操作来安装它:
Here is an official commit from django-extensions repo at GitHub:
Django-Extensions GitHub repo
You can install it by doing this:
对于 IPython 0.11.dev 修复:
For IPython 0.11.dev is fix that: