简体   繁体   English

如何在cygwin中启用python交互模式?

[英]How to enable python interactive mode in cygwin?

I like python in interactive mode when on linux.在 linux 上,我喜欢交互模式下的 python。 However on cygwin, the interactive mode doesn't start.但是在 cygwin 上,交互模式不会启动。 I don't see the ">>>" prompt and whatever I enter doesn't result in anything.我没有看到“>>>”提示,我输入的任何内容都不会产生任何结果。

Solved : I figured out the problem from the answers below.已解决:我从下面的答案中找出了问题所在。 I was using a windows installation of python and it needs -i option to start in interactive mode.我正在使用 python 的 Windows 安装,它需要-i选项才能以交互模式启动。

Try passing the -i flag to Python.尝试将-i标志传递给 Python。

I've experienced this very same thing, as have others .我和其他人一样经历过同样的事情。 There seems to be an issue with cygwin's ability to operate interactively with native-Windows applications (including Python.exe). cygwin 与本机 Windows 应用程序(包括 Python.exe)交互操作的能力似乎存在问题。 If you can, install the cygwin version of Python via cygwin's package management, as it doesn't have this interactivity problem.如果可以的话,通过cygwin 的包管理安装cygwin 版本的Python,因为它没有这个交互问题。

A Windows install of ActiveState python won't enter interactive mode, AND it will be run instead of cygwin Python even if you have cygwin Python installed, because ActiveState python inserts its bin path at the front of your Windows System PATH environment variables. ActiveState python 的 Windows 安装不会进入交互模式,即使您安装了 cygwin Python,它也会代替 cygwin Python 运行,因为 ActiveState python 将其 bin 路径插入到 Windows 系统 PATH 环境变量的前面。

I solved it by going (in Windows) to Control Panel->System -> Advanced system settings-> Environment variables, choosing PATH, selecting Edit, and cut-pasting all the ActiveState entries from the front to the back of the PATH list.我通过(在 Windows 中)转到控制面板->系统-> 高级系统设置-> 环境变量,选择 PATH,选择编辑,然后将所有 ActiveState 条目从 PATH 列表的前面剪切到后面来解决它。

I use it all the time.我用它所有的时间。

$ python
Python ****** (********) 
**********************
Type "help", "copyright", "credits" or "license" for more information.
>>> "It works"
'It works'
>>> 

If you supply a file name, or anything like that, it won't go into interactive mode by default.如果您提供文件名或类似名称,默认情况下它不会进入交互模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM