使用Cygwin中的Windows Python [英] Using Windows Python from Cygwin

查看:149
本文介绍了使用Cygwin中的Windows Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在Windows上使用Cygwin。我想使用Python的Windows安装,所以在测试期间我使用 /cygdrive/c/Python26/python.exe myfile.py 而不是 python myfile.exe



这是几乎完美的工作,除了打印。当我从Cygwin运行Windows Python时,输出不会打印,直到执行完成。它工作正常运行在Windows Python从explorer.exe或cmd.exe,它在Cygwin中使用Cygwin安装的Python( /bin/python.exe )。 / p>

有没有解决方法?重要的是能够运行Windows版本,但我想从Bash做到这一切。

解决方案

也许如果刷新输出

  import sys 

V = range(100000)
for x in V:
print x
sys.stdout.flush()


I've been using Cygwin on Windows recently. I want to use the Windows installation of Python, so during testing I'm using /cygdrive/c/Python26/python.exe myfile.py rather than python myfile.exe.

This is working almost perfectly, except for printing. When I run the Windows Python from Cygwin the output doesn't print until execution finishes. It works fine running in Windows Python from explorer.exe or cmd.exe, and it works in Cygwin using the Cygwin-installed Python (/bin/python.exe).

Is there a workaround for this? The important thing is to be able to run the Windows version, but I'd like to do it all from with Bash.

解决方案

Perhaps if you flush the output

import sys

V = range(100000)
for x in V:
    print x
    sys.stdout.flush()

这篇关于使用Cygwin中的Windows Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆