Pages

Saturday, August 29, 2015

Python For Beginners Start Code Python With Sam Lesson 2 Run Python script using command prompt

Python For Beginners Start Code Python With Sam Lesson 2 Run Python script using command prompt


hello there in previous tutorial i promised you to teach about how to run python script in command prompt
ok lets get started first create new text file and type print ('hello world')
now goto save as and give a name like hello.py remember to put extension as py after that save as type change text file to all files then save












then go to command prompt you can go to start menu and type cmd and then open cmd and type
python but it show error what is error
"python is not recognized as an internal or external command"

python is not recognized as an internal or external command Error solved 



first right click on my computer
 Go to advance settings

then go to Environmental variables and click path and click Edit

then open python folder you have installed in my computer its in c://python34 go to that folder and copy link
than go to again environmental variable path and go to end of the path (you can use arrow key to go to end of the path)
then past ; semicolon in the end of the path 
then past the previous copied path

ex existing path here ;c://python34 


now click ok ok ok now you have solve the problem
 now open command prompt again and type python now there is no errors


Run python script using command prompt


now lets run the previous created hello.py file


open command prompt

change command prompt location where the file is saved
 i saved in desktop so i change directory as cd Desktop
then type python hello.py
then it execute the python script and shows output in command prompt as hello world



all done now you know how to fix errors set path in python and how to run python script using command prompt

ok guys next tutorial im going to teaching how to install pycham IDE for fast coding
thanks for watching
have a good day
Sameera Dissanayaka

#pythonforbeginners ,#startcodepythonwithsam ,#runpythonscriptusingcmd





No comments:

Post a Comment