December 3, 2019 Python

Running Python from the Git Bash Terminal on Windows

I assume you have installed Git for Windows and want to run python from the terminal but unable to do it.

So, if you have the problem of running python from the Git bash terminal, you can fix it using the following steps:

Using a text editor in administrative mode, open the ‘aliases.sh‘ file located in your Git folder, most probably in C:\Program Files\Git\etc\profile.d folder.

After you opened the file, put the following just above the other entries labelled as ‘alias’ :

alias python=’winpty python.exe’ so that the file will become something like this:

alias python=’winpty python.exe’
alias ls=’ls -F –color=auto –show-control-chars’
alias ll=’ls -l’

For permanent use and if you don’t want to edit the aliases.sh file each time you want to use Git bash, create a file named .bashrc in the ‘user’ folder. in my case, it is
C:\Users\USER Or preferably, using the Git terminal, enter CD ~ and then touch .bashrc

Git bash terminal

The touch command will create a file called .bashrc.

Now open the file, that you just created, in your favourite text editor and insert the following entry into the editor,

alias python=’winpty python.exe’

Editing Git bash terminal

Save and exit.

Leave a Reply

Your email address will not be published. Required fields are marked *