Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 3 won't run from the Git Bash command line [duplicate]

Basically, I type python into Git Bash command line and I get back a blank line as if the command line is thinking...

I've done plenty of research but I can't seem to run python on Git Bash by typing in python into the command line.

I was looking at the question: Python not working in the command line of git bash and someone recommended to type:

winpty c:/Python34/python.exe

into the command line and it worked! However, I don't want to have to keep typing that entire command into the command line.

like image 455
Scott Avatar asked Feb 18 '16 01:02

Scott


People also ask

How do I find my Python path in git bash?

Solution: At the command prompt, paste this command export PATH="$PATH:/c/Python36" . That will tell Windows where to find Python.


5 Answers

"One caveat if using Git Bash with MinTTY: python doesn't go into interactive mode so a solution is to force it to start that way: echo alias python=\"python -i\" >> ~/.bash_profile"]

For more details

I had the same issue and using "python -i" solved it.

like image 182
apeke Avatar answered Oct 18 '22 09:10

apeke


A few of the solutions here should help you out.

Or, as @adarsh suggests, add the following to ~/.bashrc (or in ~/.bash_profile if this doesn't work for your version of Git Bash):

PATH=$PATH:c/Python34/
like image 39
hansmosh Avatar answered Oct 18 '22 07:10

hansmosh


The comment of adding it to the .bashrc is likely the best answer.

Type:

  1. open terminal
  2. cd ~ (hit enter)
  3. vim .bashrc (hit enter)
  4. Hit I to insert on one of the lines and type:
  5. alias python3='c:/Python34/python.exe'
  6. hit esc (enters vim command mode)
  7. type :wq (write and quit)
  8. hit enter

Now type python3 in gitbash hit enter and there you go!

like image 45
Dave Avatar answered Oct 18 '22 07:10

Dave


If you have two version of Python installed I would just point exe independently. example:

$ '/d/Python 3.6.4/python.exe' /d/1.APPS/gitHUBprojects/project1/project1.py

like image 29
just call me Avatar answered Oct 18 '22 07:10

just call me


@Mindputty's answer above worked best for me -- in .bash_profile -- with the addition of the -i option:

alias py="winpty C:/Python38/python.exe -i"

Also added:

alias py="winpty C:/Python38/python.exe -i"

I'm on Windows 10 (64-bit) with git-for-windows 2.25.windows.1 and python 3.8.2.

(@Mindputty - sorry, don't have enough cred to upvote. But thank you--this was driving me crazy.)

like image 30
AronGahagan Avatar answered Oct 18 '22 08:10

AronGahagan