8

I've installed python 3.5 and python 2.7 on windows. And I've added path for python 2.7 in PATH variable. When I type 'python --version' in windows cmd, it prints 2.7. But when i type 'python --version' in git bush, it prints 3.5. How to change python version in windows git bash to 2.7?

3 Answers 3

4

Follow these steps:

  1. Open Git bash, cd ~
  2. Depending on your favorite editortouch, code or vim (in my case) type code .bashrc
  3. Add the line alias python='winpty c:/Python27/python.exe' to the open .bashrc
  4. Save and Close.
  5. Try python --version on git bash again.

Hopefully it works for you.

Sign up to request clarification or add additional context in comments.

Comments

0

Try setting the path inside git bash to the correct folder.

Example:

PATH=$PATH:/c/Python27/

Comments

0

Here is what works for me on Windows 10 (a modified version of Job Collins answer):

  1. Edit .bashrc file or create it at the user home if does not exist:
    cd ~
    nano .bashrc
  1. add this line (modify the user name and the python version part, the apostrophe and quotes are important)
     alias python='winpty "C:\Users\<user name>\AppData\Local\Programs\Python\Python311\python.exe"'
  1. activate
source .bashrc 
  1. check if everything is ok
python --version

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.