我安装了ipython,然后运行./paster shell dev.ini命令,paster打开标准的python控制台。如何让它运行ipython?
发布于 2011-09-13 21:47:08
我把ipython降级到0.10版本解决了这个问题
发布于 2013-04-07 00:32:05
下面是我在Fedora17,IPython 0.12,paste-1.7.5.1和pylons 1.0上的工作原理:
$ paster shell dev.ini
Pylons Interactive Shell
Python 2.7.3 (default, Jul 24 2012, 10:05:38)
[GCC 4.7.0 20120507 (Red Hat 4.7.0-5)]
All objects from project.lib.base are available
Additional Objects:
mapper - Routes mapper object
wsgiapp - This project's WSGI App instance
app - paste.fixture wrapped around wsgiapp
>>> __name__ = '__main__'
>>> import IPython
>>> IPython.embed()
Python 2.7.3 (default, Jul 24 2012, 10:05:38)
Type "copyright", "credits" or "license" for more information.
IPython 0.12 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]:重置__name__是必要的,因为Pylons/Paste会将__name__设置为"pylons-admin",这会混淆IPython (它试图在sys.modules中通过模块的名称查找主模块)。
发布于 2011-09-13 00:01:31
您是否尝试了Pylons Quick Site Development中的步骤
使用IPython嵌入式外壳的
13.1.2
IPython提供了一个更强大的交互式提示和一个强大的嵌入式外壳。如果您是Python程序员,并且还没有尝试过IPython,那么您一定要研究一下它。
首先,从IPython导入--在控制器模块的顶部添加类似下面的内容,在我们的示例中是在firstapp/controllers/firstControler.py中:
从IPython.Shell导入IPShellEmbed args = '-pdb','-pi1','In <#>:','-pi2',‘.\D.:','-po','Out<#>:','-nosep’ipshell = IPShellEmbed(args,IPython.Shell=‘进入banner。按Ctrl-D退出。’,exit_msg =‘离开解释器,返回到IPShellEmbed。’)
然后,将此代码放入您的操作/方法中:
ipshell(‘我们在操作abc')
返回到塔架并按Ctrl-D继续响应请求。
请注意,由于IPython.Shell.IPShellEmbed的一些特殊特性,我必须在每次调用ipshell()之前放入以下内容:
ipshell.IP.exit_now = False ipshell(‘我们在操作abc')
https://stackoverflow.com/questions/7389388
复制相似问题