Python不工作在git bash的命令行 [英] Python not working in the command line of git bash

查看:657
本文介绍了Python不工作在git bash的命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Python不会在git bash(Windows)中运行。当我在命令行中键入python时,它需要我到一个空白行,而不说它已经进入python 2.7.10像它在Powershell中的做法。它不会给我一个错误消息,但python只是不运行。

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.

我已经确定PATH中的环境变量包括 c:\python27

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.

推荐答案

这是MSys2中的一个已知错误,它提供了由Git Bash使用的终端。您可以通过运行无ncurses支持的Python构建或使用 WinPTY ,使用方式如下:

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:


要在mintty或Cygwin sshd中运行Windows控制台程序, console.exe到命令行:

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()


为msys修复二进制文件很可能与Git Bash一起使用。

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!).

自Git发布以来,已经过了很长时间了,请检查是否有更新的版本。对于Windows 2.7.1,也尝试使用 winpty c:Python27 / python.exe ; WinPTY可以包括开箱即用。

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

这篇关于Python不工作在git bash的命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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