python无法运行git,Python不工作在git bash的命令行

Python will not run in git bash (Windows). When I type python in the command line, it takes me to a blank line without saying that it has entered python 2.7.10 like its does in Powershell. It doesn't give me an error message, but python just doesn't run.

I have already made sure the environmental variables in PATH included c:\python27. What else can I check?

A session wherein this issue occurs looks like the following:

user@hostname MINGW64 ~

$ type python

python is /c/Python27/python

user@hostname MINGW64 ~

$ python

...sitting there without returning to the prompt.

解决方案

This is a known bug in MSys2, which provides the terminal used by Git Bash. You can work around it by running a Python build without ncurses support, or by using WinPTY, used as follows:

To run a Windows console program in mintty or Cygwin sshd, prepend console.exe to the command-line:

$ build/console.exe c:/Python27/python.exe

Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> 10 + 20

30

>>> exit()

The prebuilt binaries for msys are likely to work with Git Bash. (Do check whether there's a newer version if significant time has passed since this answer was posted!).

As of Git for Windows 2.7.1, also try using winpty c:Python27/python.exe; WinPTY may be included out-of-the-box.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值