Python not working in the command line of git bash

Caroline Morris picture Caroline Morris · Sep 16, 2015 · Viewed 158.2k times · Source

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.

Answer

Vitaliy Terziev picture Vitaliy Terziev · Apr 10, 2016

Just enter this in your git shell on windows - > alias python='winpty python.exe', that is all and you are going to have alias to the python executable. Enjoy

P.S. For permanent alias addition see below,

cd ~
touch .bashrc

then open .bashrc, add your command from above and save the file. You need to create the file through the console or you cannot save it with the proper name. You also need to restart the shell to apply the change.