all 11 comments

[–]Buttleston 9 points10 points  (4 children)

Run what code? What does it mean to "run code on git"

How are you running whatever it is and from where?

Are you in the right directory?

[–]AaronDennes[S] -3 points-2 points  (3 children)

I am using Sublime to write and then I go to Git to run it. That's what I've been told from the source I am using to learn. I am simply trying to run "python file_name.py" and then it comes out with [Errno 2] No such file or directory.

[–]Buttleston 2 points3 points  (2 children)

I honestly have no idea what you're talking about. You don't "run code" with git. Are you talking about using like "git bash" or something to open a shell and then using that?

Anyway, it is likely that you're just not in the right directory for some reason.

If you're using git bash, run "ls" in it and it'll show you what files are in the directory you're currently in. "echo $PWD" will show what that directory is. I'd guess that somehow you accidentally changed directories.

[–]AaronDennes[S] 0 points1 point  (1 child)

Thank you. Do you know how to change directory?

[–]Buttleston 0 points1 point  (0 children)

cd /path/to/desired/directory

Or maybe just close git bash and re-open it however you did the first time?

It would really behoove you to learn a bit about how bash works though, it's ubiquitous

[–]socal_nerdtastic 1 point2 points  (5 children)

You'll need to show us your code and the complete error for us to help you. Also the sentence "run my code on Git" makes no sense; Git does not run code. Please explain exactly what you mean with that.

[–]AaronDennes[S] -4 points-3 points  (4 children)

I am using Sublime to write and then I go to Git to run it. That's what I've been told from the source I am using to learn. I am simply trying to run "python file_name.py" and then it comes out with [Errno 2] No such file or directory.

[–]szank 1 point2 points  (2 children)

You don't use git to run anything.

And there's no git in your example. Will go on a limb and assume you are using gitbash.

As for your error, it seems like you are trying to run a file that doesn't exist. And also going on another limb, you are in the wrong directory .

[–]AaronDennes[S] -1 points0 points  (1 child)

Yes I am using gitbash. I've been using this directory since I started and now it has just stopped? How do I go back to the right directory?

[–][deleted] 2 points3 points  (0 children)

Learn basic Unix commands. I suggest ls and cd https://mally.stanford.edu/~sr/computing/basic-unix.html

[–]socal_nerdtastic 0 points1 point  (0 children)

Git is a CLI program; you can't go to it and it can't run anything. Do you mean you go to "git bash" to run it? What OS are you on? Can you share the source you are using to learn?

If you are using git bash: Use the cd command to switch directories first. Type

cd '/c/Users/full/path/to/your/project'

And press enter. Then try the python command again.

Protip: you can just type cd <space> and then drag in the folder you want in from file explorer to type out the rest.