在 Emacs 下安装 python-mode 后,可以在 Emacs 中调用 Python Shell:
C-c C-c 打开一个新的Python Shell
C-c RET run current Python file, 如下图:

C-x k 可以退出这个shell, 也就是kill buffer (我现在粗浅地将buffer理解为每一个窗口)。
问题来了,如果再一次C-c RET 跑这个文件,会给出buffer has no process。
究其原因,在http://www.cs.vassar.edu/~priestdo/emacspeak/list.archive.2002/msg00248.html
找到了解释:
This happens if yu are running term and you type 'exit' or possibly 'logout' while in the term buffer. When you do this, the shell process you are running is killed and emacs doesn't know what to do anymore - it was taking its imput from the inferior shell process and sending output to that process, but when you typed 'exit' you killed that process and emacs doesn't know what to do with your input anymore. Solution is very simple. Don't exit/kill the terminal process. If you no longer need the term process, then kill the buffer (from within term this is C-x k), or switch to another buffer and then kill the term buffer. Better still, just leave it alone - you will probably want it again and if its already running, you don't have to start another one, just switch to that buffer with C-x b.
简单来说,就是我已经把buffer kill掉了, Emacs就不知道接下来该干嘛了。
解决的办法就是保留这个buffer,或者再新建一个buffer, C-x b
但是使用 C-x k kill buffer 以后,新建一个buffer,再用C-c RET, 同样显示buffer has no process。
原因是kill的时候没有停止process
停止process的方法就是 C-d
这样shell里面就会显示,process python finished
此时可以kill buffer,再一次C-c RET的话,就不会显示buffer has no process
本文介绍在Emacs编辑器中使用PythonShell的方法及常见问题解决方案,包括如何正确关闭和重启Python进程,避免出现bufferhasnoprocess错误。
1136

被折叠的 条评论
为什么被折叠?



