1

I'm trying to set up python as an alias on my git bash and I've edited both my .bashrc and .bash_profile to have the alias. I've edited both files and I am still getting a command not found prompt within Git Bash: bash-screenshot

.bashrc and .bash_profile:

if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
# Enable tab completion
source ~/git-completion.bash
alias python="~\AppData\Local\Programs\Python\Python35\python.exe"

Anybody have any ideas?

6
  • Are you sure of the python path? C:\Users\<username>\AppData\Local\Programs\Python\Python35\python.exe Commented Aug 8, 2017 at 21:33
  • yup when I open file explorer and right click and go to properties that's the path Commented Aug 8, 2017 at 21:37
  • 1
    What if you use forward slashes? alias python=~/AppData/Local/Programs/Python/Python35/python.exe Commented Aug 8, 2017 at 21:39
  • The problem is definitely with your slashes as @janos said. Commented Aug 8, 2017 at 21:43
  • I wouldn't set an alias but rather a path to the python command. python.exe is found when typing python on Windows bash/mingw/whatever (or it would be very unpractical) Commented Aug 8, 2017 at 21:53

1 Answer 1

3

Unlike python, backslashes not escaping anything are removed in bash.

So

alias python="~\AppData\Local\Programs\Python\Python35\python.exe"

creates an alias to ~AppDataLocalProgramsPythonPython35python.exe

Fix:

alias python="~/AppData/Local/Programs/Python/Python35/python.exe"

or just set the path (.exe suffix is supported on Windows flavours of bash)

export PATH=$PATH:~/AppData/Local/Programs/Python/Python35

(so programs not having access to aliases/shell built-ins can still run python using subprocess or exec)

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

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.