Pylons Paster shell 无法在 ipython 中运行

发布于 2024-12-04 02:09:00 字数 104 浏览 1 评论 0原文

我安装 ipython,然后运行 ./paster shell dev.ini 命令,粘贴打开标准 python 控制台。我怎样才能让它运行ipython?

I install ipython, and then i run
./paster shell dev.ini
command, paster open standard python console. How can I make it run ipython?

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

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

发布评论

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

评论(6

吝吻 2024-12-11 02:09:00

以下是它在 Fedora 17 上使用 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)。

Here's how it worked for me on Fedora 17 with IPython 0.12, paste-1.7.5.1 and 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]:

Resetting __name__ is necessary because either Pylons/Paste sets __name__ to "pylons-admin" which confuses IPython (it tries to lookup the main module by its name in sys.modules).

柠栀 2024-12-11 02:09:00

我解决了这个问题,将 ipython 降级到 0.10 版本

I solved this problem downgrading ipython to version 0.10

千里故人稀 2024-12-11 02:09:00

您是否尝试过Pylons Quick Site Development<中的步骤/a>:

13.1.2 使用 IPython 嵌入式 shell

IPython提供了更强大的交互提示和强大的
嵌入式外壳。如果你是一名Python程序员并且还没有尝试过
IPython,你绝对应该研究一下。

首先,从 IPython 导入——在
控制器模块的顶部,在我们的例子中
firstapp/controllers/firstcontroller.py:

从 IPython.Shell 导入 IPShellEmbed args = ['-pdb', '-pi1', 'In
<\#>: ', '-pi2', ' .\D.: ',
'-po', 'Out<\#>: ', '-nosep'] ipshell = IPShellEmbed(args,
横幅 = '进入 IPython。按 Ctrl-D 退出。',
exit_msg = '离开解释器,返回 Pylons。')

然后,将此代码放入您的操作/方法中:

ipshell('我们正在采取行动 abc')

返回 Pylons 并按按继续响应请求
Ctrl-D。

请注意,由于
IPython.Shell.IPShellEmbed,我必须在每个之前添加以下内容
调用 ipshell():

ipshell.IP.exit_now = False ipshell('我们正在采取行动 abc')

Did you try the steps from the Pylons Quick Site Development:

13.1.2 Using an IPython embedded shell

IPython provides a more powerfull interactive prompt and a powerful
embedded shell. If you are a Python programmer and have not yet tried
IPython, you definitely should look into it.

First, import from IPython -- Add something like the following at the
top of your controller module, in our case in
firstapp/controllers/firstcontroller.py:

from IPython.Shell import IPShellEmbed args = ['-pdb', '-pi1', 'In
<\#>: ', '-pi2', ' .\D.: ',
'-po', 'Out<\#>: ', '-nosep'] ipshell = IPShellEmbed(args,
banner = 'Entering IPython. Press Ctrl-D to exit.',
exit_msg = 'Leaving Interpreter, back to Pylons.')

Then, place this code in your action/method:

ipshell('We are at action abc')

Return to Pylons and continue on responding to the request by pressing
Ctrl-D.

Note that because of some idiosyncratic feature of
IPython.Shell.IPShellEmbed, I had to put the following before each
call to ipshell():

ipshell.IP.exit_now = False ipshell('We are at action abc')

素染倾城色 2024-12-11 02:09:00

您的 ipython 是否有可能全局安装,但您从 virtualenv 运行 pylon那是--no-site-packages?如果是这种情况,那么 pylons 将看不到您安装的 ipython。

Is there any chance that your ipython is installed globally, but that you're running pylons from a virtualenv that is --no-site-packages? If that's the case, then pylons won't see your installation of ipython.

心的位置 2024-12-11 02:09:00

Ipython 最近更新到了 .11 版本。某些组件不再正常工作,尤其是使用第三方库时。检查 pylon 的邮件列表,您可能需要考虑错误报告。

Ipython updated to version .11 just recently. Some of the components no longer work correctly, especially with 3rd party libraries. Check the mailing lists for pylons, and you may want to consider a bug report.

伤痕我心 2024-12-11 02:09:00

试试这个:

paster ishell dev.ini

Try this:

paster ishell dev.ini
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文