在Windows上调用CygWin下的python挂起 [英] Invoking python under CygWin on Windows hangs

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

问题描述

安装一个新的Windows系统,我已经安装CygWin和64
位Python(2.7.3)在他们的默认位置( c:\cygwin
c:\ Python27 \ python ),并将CygWin bin和
Python目录添加到我的路径路径)。从
正常的命令窗口,Python完全启动,但是当
我从CygWin环境中的 bash 调用它挂起,$ b $

Installing a new Windows system, I've installed CygWin and 64 bit Python (2.7.3) in their default locations (c:\cygwin and c:\Python27\python), and added both the CygWin bin and the Python directory to my path (in the user variable PATH). From the normal command window, Python starts up perfectly, but when I invoke it from bash in the CygWin environment, it hangs, never giving my the input prompt.

我以前在其他机器上做过,但总是使用
的旧版本的Python(32位)和CygWin和Python
在一个决定性的非标准位置。有没有人有这个
的问题,或者有人可以告诉我什么可能是由于?

I've done this on other machines, previously, but always with older versions of Python (32 bits) and CygWin, and with Python in a decidely non-standard location. Has anyone else had this problem, or could someone tell me what it might be due to?

推荐答案

问题是,由于Cygwin终端(MinTTY)的行为方式,Python的本机Windows构建不'实现stdout是一个终端设备 - 它认为它是一个管道,所以它运行在非交互模式,而不是交互模式,它完全缓冲其输出,而不是行缓冲它。

The problem is that due to the way that the Cygwin terminal (MinTTY) behaves, the native Windows build of Python doesn't realize that stdout is a terminal device -- it thinks it's a pipe, so it runs in non-interactive mode instead of interactive mode, and it fully buffers its output instead of line-buffering it.

这是新的原因很可能是因为在您以前的Cygwin安装中,您没有MinTTY,并且使用的终端只是标准的Windows终端。

The reason that this is new is likely because in your previous Cygwin installation, you didn't have MinTTY, and the terminal used was just the standard Windows terminal.

为了解决这个问题,你需要从普通的Windows终端( Cmd.exe )运行Python,或者安装Cygwin版本的Python代替Python的本机Windows构建。 Cygwin版本(通过Cygwin的 setup.exe 可以安装为一个软件包)了解Cygwin终端,并在运行MinTTY时适当地执行。

In order to fix this, you either need to run Python from a regular Windows terminal (Cmd.exe), or install the Cygwin version of Python instead of a native Windows build of Python. The Cygwin version (installable as a package via Cygwin's setup.exe) understands Cygwin terminals and acts appropriately when run through MinTTY.

如果您想要的特定版本的Python不是Cygwin软件包,那么您也可以下载Python的源代码,并在Cygwin下创建它。你将需要一个Cygwin编译器工具链,如果你还没有一个(GCC),但我相信它应该编译一个标准的 ./ configure&&制作&& make install 命令。

If the particular version of Python you want is not available as a Cygwin package, then you can also download the source code of Python and build it yourself under Cygwin. You'll need a Cygwin compiler toolchain if you don't already have one (GCC), but then I believe it should compile with a standard ./configure && make && make install command.

这篇关于在Windows上调用CygWin下的python挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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