-1

I'm trying to open a .py file on git bash but it doesn't work.

I have tried to follow some instructions like running python <filename> but it doesn't work for me.

When I run

python python_basics

I expect it will open the .py file but it says it can't open file 'python_basics':

[Errno 2] No such file or directory

Aimery
  • 1,559
  • 1
  • 19
  • 24
PhmHiu
  • 23
  • 9
  • 1
    If the file is called `python_basics.py` then you must call `python python_basics.py`. – mkrieger1 Jul 04 '19 at 09:14
  • oh when i do like u said,nothing happen,even it doesn't pop any issue, it just show ~$ like normal – PhmHiu Jul 04 '19 at 09:26
  • What should it do instead? Is `python_basics.py` supposed to generate some output? – mkrieger1 Jul 04 '19 at 09:30
  • yeah,it will pop up some statements/expressions for me to enter the output of these to move on – PhmHiu Jul 04 '19 at 09:38
  • Have you tried running `python python_basics.py` from Command Line or PowerShell? Also, what happens if you just run `python`(no arguments) in Git Bash? (I'm assuming you are running Windows since you use Git Bash.) – Aimery Jul 04 '19 at 10:04
  • Could you show the code? Normally statements and expressions don't produce any output, the script will just run from start to finish and you won't see anything. – mkrieger1 Jul 04 '19 at 10:05
  • how to show the code?it is quite long,i take it from here to practice with python https://cs61a.org/lab/lab00/ you can scroll down to the Doing the assignment part,it is supposed to be just like that i think – PhmHiu Jul 04 '19 at 10:13
  • can you guys help me :( i really want to learn python,i'm now starting from zero – PhmHiu Jul 04 '19 at 10:59
  • Possible duplicate of [Python not working in the command line of git bash](https://stackoverflow.com/questions/32597209/python-not-working-in-the-command-line-of-git-bash) – Aimery Jul 04 '19 at 12:12

3 Answers3

0

From this question, the problem may very well be caused by Git Bash itself.

I would recommend you try running your Python file from a different terminal (Command Prompt or PowerShell if you are using Windows), using the command suggested in the comments:

python python_basics.py

Aimery
  • 1,559
  • 1
  • 19
  • 24
0

Thank you for your question, I am here to help you and who will see this question.

if you mean you want to open the file like when click on the file and open it you can use this command

Start filename.py

but if you want to open the file inside the gitbash use this command

vim filename.py

and if you mean to run the file from gitbash you can use this command

python pythonFileName.py

Now if the above command did not work with you, and you are in the windows10 Pro platform you should go to

environment variable >> Then system variable >> then choose path >> then Edit >> and put the python path >> restart the terminal and run it again

Notice: All of the above I tried and used in windows10 pro.

Thanks,

Hope to help anyone,

-1

First check the python version installed on your system. by command- python --version. If not found set $ PATH=$PATH:/c/Python27/

Adapting the path will solve your problem.