This guide walks you through installing Git and Python on Windows (if you haven't already) and getting Python to actually work inside Git Bash—including fixing that annoying issue where the Python REPL just freezes up or refuses to open.
Already got both Git Bash and Python installed? Cool, jump straight to Step 1.
-
Grab Git for Windows from the official site:
https://git-scm.com/download/win -
Run the installer and stick with the default options unless you have a specific reason to change things.
-
Make sure Git Bash is selected during installation.
-
Once it's done, open Git Bash from the Start Menu.
Check that it installed correctly:
git --versionYou should see something like:
git version 2.x.x.windows.x
-
Download Python from the official site:
https://www.python.org/downloads/windows/ -
Run the installer.
-
On the first screen, make sure you check this box:
☑ Add Python to PATH
- Hit Install Now.
Check that it works (in Command Prompt, not Git Bash yet):
python --versionYou should see:
Python 3.x.x
If Python isn't recognized, restart your computer and give it another shot.
Fire up Git Bash from the Start Menu.
cd ~
pwdYou should see:
/c/Users/YourUsername
Or close and reopen Git Bash.
Check the Python version:
python --versionStart the Python shell:
pythonYou should see:
Python 3.x.x (default, ...)
>>>
Exit Python:
exit()- Make sure Python was installed with the "Add Python to PATH" option checked
- Double-check that the correct Python path was added to .bashrc
- Restart Git Bash after making changes
- Confirm the winpty alias exists in .bashrc
- Restart Git Bash
Check which Python Git Bash is actually using:
which python| Task | Command |
|---|---|
| Edit bash config | nano ~/.bashrc |
| Reload config | source ~/.bashrc |
| Check Python version | python --version |
| Start Python shell | python |
- https://prishitakapoor2.medium.com/configuring-git-bash-to-run-python-for-windows-a624aa4ae2c5
- Git for Windows Documentation
- Python Official Documentation