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:
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.I don't see next option in a list of answers, but I can get interactive prompt with "-i" key:
In addition to the answer of @Charles-Duffy, you can use winpty directly without installing/downloading anything extra. Just run
winpty c:/Python27/python.exe
. The utility winpty.exe can be found at Git\usr\bin. I'm using Git for Windows v2.7.1The prebuilt binaries from @Charles-Duffy is version 0.1.1(according to the file name), while the included one is 0.2.2
Another example of this issue is using the AWS Elastic Beanstalk command line interface (awsebcli, eb cli) from the git bash (MINGW64, Mintty) in windows (using git version 2.19.0.windows.1).
I'm just posting this because it took me a while to end up here, searching for
eb-cli
specific issues.Commands such as
eb init
oreb config save
, which require user input, appear to cause a freeze/hang. In reality I guess the console is not updated with the text requesting user input. Moreover,eb deploy
only updates the console text after the command has finished, so I don't get to see progress updates until finished.As mentioned in the git for windows release notes (for v2.19.0) and e.g. in Xun Yang's answer, a workaround is to run
winpty eb <command>
(instead of justeb <command>
)A alternative, as suggested in this git for windows issue, could be to use the windows native console instead of mintty (option during git installation).
In addition to @Vitaliy Terziev answer
try
touch .bash_profile
and then add alias into the file.type: 'winpty python' and it will work
gitbash has some issues when running any command that starts with python. this goes for any python manage.py commands as well. Always start with 'winpty python manage.py' At least this is what works for me. Running Windows 10.