相关疑难解决方法(0)

禁用输出缓冲

Python的解释器默认启用输出缓冲sys.stdout吗?

如果答案是肯定的,那么禁用它的所有方法是什么?

建议到目前为止:

  1. 使用-u命令行开关
  2. 包装sys.stdout在每次写入后刷新的对象
  3. 设置PYTHONUNBUFFEREDenv var
  4. sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)

是否有任何其他方式来设置一些全局标志sys/ sys.stdout程序执行过程中?

python stdout buffered

487
推荐指数
10
解决办法
25万
查看次数

如何在Windows上的Emacs中以交互方式运行node.js

我认为这会奏效:

(defun my-node ()
  (interactive)
  (pop-to-buffer (make-comint "my-node" "node")))
Run Code Online (Sandbox Code Playgroud)

但是当我这样做M-x my-node并进入1+1comint缓冲区时,它不会显示任何输出.

这是在Windows 7上的Emacs 24.0.50.1中安装的NodeJS没有任何特殊配置.

以非交互方式调用node.js,因为M-x compile RET node hello-world.js RET工作正常.node交互式运行cmd工作正常.

这可能是相关的:当我运行M-x shell并输入nodeshell缓冲区然后输入时1+1,它不会显示结果.我必须遗漏一些非常基本的东西.

更新:

可能相关:emacs/Python:在行缓冲与块缓冲模式下运行python-shell - Stack Overflow

javascript emacs node.js

12
推荐指数
2
解决办法
4346
查看次数

在matplotlib show()命令之后,Emacs Python-inferior shell没有显示提示

所以我一直在尝试使用numpy和matplotlib,并且在从emacs劣质shell运行python时遇到了一些错误.

当我将py文件发送到shell解释器时,我可以在代码执行后运行命令.命令提示符">>>"显示正常.但是,在我在一个绘图上调用matplotlib show命令之后,shell就会挂起,而命令提示符没有显示.

>>> plt.plot(x,u_k[1,:]);
[<matplotlib.lines.Line2D object at 0x0000000004A9A358>]
>>> plt.show();
Run Code Online (Sandbox Code Playgroud)

我正在运行传统的C-python实现.在emacs 23.3下使用Fabian Gallina的Python python.el v.0.23.1在Win7上.

在i-python平台下提出了一个类似的问题:在windows上的emacs里面的py-shell上运行matplotlib或enthought.mayavi.mlab

更新:我在Win 7 x64的新安装上重复了这个问题,python网站上提供了典型的python 2.7.2二进制文件,在emacs 23.3和23.4上用于Windows的numpy 1.6.1和matplotlib 1.1.0.

emacs shell中某处必定存在错误.

python emacs matplotlib

9
推荐指数
1
解决办法
2691
查看次数

Emacs:Inferior-mode python-shell出现"滞后"

我是一个Python(3.1.2)/ emacs(23.2)新手教我自己tkinter使用这里找到的pythonware教程.相关代码粘贴在问题下方.

问题:当我单击Hello按钮(应该调用say_hi函数)时,为什么劣质python shell(即我用Cc Cc启动的那个)等待执行say_hi打印功能,直到我a)单击退出按钮或b)关闭根小部件?当我在IDLE中尝试相同时,每次单击Hello按钮都会在IDLE python shell中立即打印,甚至在我单击Quit或关闭根小部件之前.

emacs运行Python shell(相对于IDLE)会导致这种"滞后"行为的方式有些怪癖吗?我已经注意到类似的emacs滞后与IDLE,因为我已经解决了Project Euler问题,但这是我见过的最明显的例子.

仅供参考:我使用python.el并且有一个相对干净的init.el ...

(setq python-python-command"d:/ bin/python31/python")

是我的init.el中唯一的一行.

谢谢,

麦克风

===开始代码===

from tkinter import *

class App:

    def __init__(self,master):

        frame = Frame(master)
        frame.pack()

        self.button = Button(frame, text="QUIT", fg="red", command=frame.quit)
        self.button.pack(side=LEFT)

        self.hi_there = Button(frame, text="Hello", command=self.say_hi)
        self.hi_there.pack(side=LEFT)

    def say_hi(self):
        print("hi there, everyone!")

root = Tk()

app = App(root)

root.mainloop()
Run Code Online (Sandbox Code Playgroud)

python emacs

6
推荐指数
1
解决办法
949
查看次数

标签 统计

emacs ×3

python ×3

buffered ×1

javascript ×1

matplotlib ×1

node.js ×1

stdout ×1