Bpython in Emacs?

Registered by Andreas Roehler

http://groups.google.com/group/bpython/browse_thread/thread/42ca849ae909753d
Hi all,

I use emacs as my primary development environment. I'd like to be
able to use bpython inside of emacs as my Python shell for testing and
such. When I simply run bpython in shell-mode, it doesn't work:

 bradpowers@bpow-rosdev:~$ bpython
 Traceback (most recent call last):
   File "/usr/local/bin/bpython", line 9, in <module>
     load_entry_point('bpython==0.10', 'console_scripts', 'bpython')()
   File "/usr/local/lib/python2.6/dist-packages/bpython-0.10-py2.6.egg/
bpython\
 /cli.py", line 1756, in main
     banner=banner)
   File "/usr/local/lib/python2.6/dist-packages/bpython-0.10-py2.6.egg/
bpython\
 /cli.py", line 1658, in curses_wrapper
     return func(stdscr, *args, **kwargs)
   File "/usr/local/lib/python2.6/dist-packages/bpython-0.10-py2.6.egg/
bpython\
 /cli.py", line 1701, in main_curses
   main_win, statusbar = init_wins(scr, config)
 File "/usr/local/lib/python2.6/dist-packages/bpython-0.10-py2.6.egg/
bpython\
 /cli.py", line 1538, in init_wins
   main_win = newwin(background, h - 1, w, 0, 0)
 File "/usr/local/lib/python2.6/dist-packages/bpython-0.10-py2.6.egg/
bpython\
 /cli.py", line 1638, in newwin
   win = curses.newwin(*args)
_curses.error: curses function returned NULL

Any recommendations on how to get emacs and bpython to play nicely
together?

Thanks,
Bradley Powers

Bob Farrell
View profile
  More options Jul 26 2011, 10:36 am
Hi Bradley,

I don't use emacs so can't be much help here, other than to tell you
that I have definitely seen bpython running inside emacs.

If I remember correctly there was some requirement for ... well, all I
can remember is something about ANSI colours.

This may or may not be relevant and could be a figment of my
imagination. But hopefully your perseverance and the help from emacs
users here will help you. I'm sure Andreas is typing a response right
now, in fact. ;-)

On 25 July 2011 21:58, Bradley Powers <email address hidden> wrote:

- Show quoted text -

Beni Cherniavsky-Paskin
View profile
  More options Jul 26 2011, 1:08 pm

Try M-x ansi-term instead of M-x shell.
bpython works for me under it, but is painfully slow (YMMV).

However, this does not give you any of the M-x python-shell integration!
I heard people using ipython as their emacs python-shell; I don't know how
hard would it be to do it with bpython, but it doesn't sound easy.

[ansi-term a full terminal emulator, so full-screen applications work inside
it.
OTOH, char-by-char terminal emulation means you lose emacsy features of M-x
shell (history, dabbrev, isearch...).
Happily, you can use C-c C-j and C-c C-k to toggle between char and line
modes - in line mode it's similar to M-x shell.
http://snarfed.org/why_i_run_shells_inside_emacs has good tips if you like
it.]

related:
http://unix.stackexchange.com/questions/34497/why-dialog-doesnt-support-emacs-shell-on-debian

Am 28.01.2013 13:17, schrieb Sebastian Ramacher:> Hi,
>
> On 2013-01-27 15:53:31, Mike Vella wrote:
>> I have the identical problem.
>>
>> On Monday, July 25, 2011 9:58:34 PM UTC+1, Bradley Powers wrote:
>>>
>>> Hi all,
>>>
>>> I use emacs as my primary development environment. I'd like to be
>>> able to use bpython inside of emacs as my Python shell for testing and
>>> such. When I simply run bpython in shell-mode, it doesn't work:
>>>
>>>
>>> bradpowers@bpow-rosdev:~$ bpython
>>> Traceback (most recent call last):
>>> File "/usr/local/bin/bpython", line 9, in <module>
>>> load_entry_point('bpython==0.10', 'console_scripts', 'bpython')()
>>> File "/usr/local/lib/python2.6/dist-packages/bpython-0.10-py2.6.egg/
>>> bpython\
>>> /cli.py", line 1756, in main
>>> banner=banner)
>>> File "/usr/local/lib/python2.6/dist-packages/bpython-0.10-py2.6.egg/
>>> bpython\
>>> /cli.py", line 1658, in curses_wrapper
>>> return func(stdscr, *args, **kwargs)
>>> File "/usr/local/lib/python2.6/dist-packages/bpython-0.10-py2.6.egg/
>>> bpython\
>>> /cli.py", line 1701, in main_curses
>>> main_win, statusbar = init_wins(scr, config)
>>> File "/usr/local/lib/python2.6/dist-packages/bpython-0.10-py2.6.egg/
>>> bpython\
>>> /cli.py", line 1538, in init_wins
>>> main_win = newwin(background, h - 1, w, 0, 0)
>>> File "/usr/local/lib/python2.6/dist-packages/bpython-0.10-py2.6.egg/
>>> bpython\
>>> /cli.py", line 1638, in newwin
>>> win = curses.newwin(*args)
>>> _curses.error: curses function returned NULL
>>>
>>>
>>> Any recommendations on how to get emacs and bpython to play nicely
>>> together?
>
> According to [1], curses just isn't usable in an Emacs terminal.
>
> Regards
>
> [1] http://unix.stackexchange.com/questions/34497/why-dialog-doesnt-support-emacs-shell-on-debian
>

Blueprint information

Status:
Complete
Approver:
None
Priority:
Not
Drafter:
None
Direction:
Needs approval
Assignee:
None
Definition:
Obsolete
Series goal:
None
Implementation:
Unknown
Milestone target:
None
Completed by
Andreas Roehler

Related branches

Sprints

Whiteboard

bpython seems not to run from an Emacs-shell at all - changing this seems out of scope.

Citing a workaround from here:

http://emacs.stackexchange.com/questions/6012/is-it-possible-to-transform-emacs-to-something-like-bpython

You may also be interested in bpython-curtsies along with the new "send session to editor" functionality (triggered by F7) which throws your entire session in emacs for modification, then re-executes it when you close the file. I like this workflow for combining the power of a text editor with the interactive features of bpython. You might also like "reimport," (F6) which reruns the entire bpython session including reimporting imported modules - another way to combine text editor and the

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.