r/learnpython • u/South-Put-7948 • 1d 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!
7
Upvotes
3
u/Entire_Ad_6447 1d ago
Do you have python installed?
1
u/PonkMcSquiggles 1d ago
Assuming that you have Python installed and in your path, the command for running a Python file is just
python [path to file]
1
u/avalexva 1d ago
Hey!
what your system?
Windows
Open Command Prompt or PowerShell, then:
or for mac and linux
or open you provider in dir with your file, and right click + shift (this for windows) "run powershell here"
1
u/Due-Mortgage-6854 1d ago
pythonorpython3orpyfollowed by yourPATH/file.py1
u/EszterSantos72 1d ago
Type python3 before your file path, like python3 myscript.py. On some systems just python works, but if you have both Python 2 and 3 installed, python3 makes sure you run the right version.
0
u/bra1n_gym 1d ago
python -m file means run this file.py as a module. you don't have to add the .py extension