Lets say I write a program that prints hello world in Python in notepad++, where do I run that code? I have Python downloaded on my computer but I don't know how to run saved code.
Four answers:
?
2012-11-14 20:27:49 UTC
should be able to navigate to a folder in terminal and then python FileName.py
also might be able to just double click on the file if i remember correctly
or right click and open with python 2.x/3.x depending on which version of python your coding on and which you have installed
boddison
2016-10-24 15:10:06 UTC
through capacity of no capacity am I an expert in python, yet attempt only conserving your variables as numbers i.e. a = 32 b = 31 then attempt it once more advantageous. also, interior the adventure that your coding software has a debug mode they you're prepared to run it from there, or attempt compiling it and sorting out it. What your doing is only mutually with 32 to the precise of the enter string making it say "Please pick a style: 32" somewhat of putting forward "Please pick a style:" once you run it the 2d way. This wont furnish a or b actually archives , it is going to in uncomplicated words change what it says even as it asks for the style.
2012-11-16 19:03:50 UTC
Well it depends on wither or not you have your python interpreter set up with your path variable. If you don't then you'll have to type out the full filename of the python interpreter then the name of your program. If it is, then all you should have to do is type python filename.py
Russel
2012-11-15 04:06:08 UTC
In windows right click on the script and click "Edit with IDLE". When the window opens up hit F5.
...or...
Google "adding python to system environment variables" and follow the steps. Then when that done you can do. winkey+r to open the run dialogue box. Type command and hit enter to open Command Prompt (or just find it in the start menu). The in Command Prompt, navigate to the folder where your script is saved (google it). When you're in the right folder, if you're script is named myscript.py then you can do
python myscript.py
to run it. Or if you want to run it in the interactive interpreter so you can fiddle with and tweak it a bit when it's done then do
python -i myscript.py
On linux, python is already there and set to go. Navigate to the correct folder like above and do the same. Or download IDLE for linux.
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Search results for 'How do I run a Python program?' (Questions and Answers)