r/learnpython • • 11h ago

About running python code in terminal

Guys, I am beginner. I have the python code and have saved in file. Now I want to place the file path in the terminal and run that code. I don't know what should I write before adding the file path? Please help!

5 Upvotes

16 comments sorted by

View all comments

1

u/avalexva 10h ago

Hey!
what your system?
Windows

Open Command Prompt or PowerShell, then:

python DISKNAME:\path\to\your\script.py

or for mac and linux

python /path/to/your/script.py

or open you provider in dir with your file, and right click + shift (this for windows) "run powershell here"

1

u/socal_nerdtastic 10h ago

for mac and linux it needs to be python3, unless you have a venv activated.

(I know the PSF recommends using python but afaik only 1 linux distro follows that)

1

u/avalexva 10h ago

Yes, that’s true—you don’t often type that out in an IDE.

1

u/South-Put-7948 9h ago

Thank you so much, Yaa it was in Mac and Python3 made it work

1

u/South-Put-7948 9h ago

Thank you so much It worked