开发者

Pylons paster shell does not run in 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?开发者_StackOverflow中文版


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).


I solved this problem downgrading ipython to version 0.10


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')


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.


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.


Try this:

paster ishell dev.ini
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜