Git Bash Workaround- Launch Python 2 & Python 3 with aliases
HI. This is (for me) the best solution to run both Python (Python 2.7 and Python 3.x) directly from Git Bash on Win 10 => adding aliases into the aliases file that Git Bash uses for.
Git Bash aliases file is aliases.sh. It is located in:
C:\path where you installed Git\etc\profile.d\aliases.sh
1) Open (with a text editor like Atom or other) the aliases.sh
for ex: in my case the file is in C:\Software\Develop\Git\etc\profile.d\aliases.sh
2) Add your alias for Python
In my case the python.exe are installed in:
C:\Networking\Network Automation\Python 2.7\python.exe
C:\Networking\Network Automation\Python 3.7\python.exe
So you must create 2 aliases, one for Python 2 (I named python2) and the other for Python 3 (I named just python)
Git Bash uses linux file structure so you need to change the "\" for "/"
and if you have a path like my example Network Automation you put it with " "
"Network Automation", for ex.
winpty is the magic command that will call the executable.
So add these lines at the beginning of aliases.sh
alias python2='winpty C/Networking/"Network Automation"/"Python 2.7"/python.exe'
alias python='winpty C/Networking/"Network Automation"/"Python 3.7"/python.exe'
3) Add or Modify other aliases (if you want)
I modified also the ll alias to show all the files and in a human readable list:
alias ll='ls -lah'
4) Save the aliases.sh file
5) OK!!! close and relaunch your Git Bash
Now, permanently you could launch both Python directly from Git shell just writting
$ python
-> launch Python 3
$ python2
-> launch Python 2
$ ll
-> enters a ls -lah to quickly show your detailed file list
Cheers, Harry
python -i
solves it. – nngeek