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.
Have a look at this answer:
Git Bash won't run my python files?
the path in Git Bash should be set like this:
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. EnjoyP.S. For permanent alias addition see below,
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.
I am windows 10 user and I have installed GIT in my system by just accepting the defaults.
After reading the above answers, I got 2 solutions for my own and these 2 solutions perfectly works on GIT bash and facilitates me to execute Python statements on GIT bash.
I am attaching 3 images of my GIT bash terminal. 1st with problem and the latter 2 as solutions.
PROBLEM - Cursor is just waiting after hitting
python
commandSOLUTION 1
Execute
winpty <path-to-python-installation-dir>/python.exe
on GIT bash terminal.Note: Do not use
C:\Users\Admin
like path style in GIT bash, instead use/C/Users/Admin
.In my case, I executed
winpty /C/Users/SJV/Anaconda2/python.exe
command on GIT bashOr if you do not know your username then execute
winpty /C/Users/$USERNAME/Anaconda2/python.exe
SOLUTION 2
Just type
python -i
and that is it.Thanks.
You can change target for Git Bash shortcut from:
to
This is the way ConEmu used to start git bash (version 16). Recent version starts it normally and it's how I got there...
I am using MINGW64 via Visual Studio Code on Windows 10 and trying to install
node-sass
(which requirespython2
). I followed felixrieseberg/windows-build-tools #56 on Github which solved my issue.This is a special case, but I'm posting in case someone has the same problem:
npm --add-python-to-path='true' --debug install --global windows-build-tools
This installs python and other required build tools to
%USERPROFILE%\.windows-build-tools\python27
.