![]() |
Still very new to this.
Ive gone through the tutorials many times and Im simply convinced there's something wrong with my version. Right now, and usually when Im writing, I have 3 tabs. The command line, the shell, and the editor. Ok, fine. I write out a sample program in the editor and go to run it, it asks me to save which is cool. Then the program runs in the shell nicely. The problem lies when I try to run the program on the command line with 'python (name of program)'. I always get a syntax error. I followed the writing and saving or saving and finding the programs directions to the T, but I can't seem to run a program using the 'python' command or I can't at all run a program on the command line. Whats up? Further, when Python asks me to save a program which Ive just written before running it, I do and I give it a name... but I dont see the other programs in there at all. Even when I use, 'start, run, browse, foldername' it's not there. Where did they go?? The only way I can open a saved program is by using the editor and clicking File, Open... that's it! There's gotta be other ways, no? |
Make sure you've saving the files as .py and when you run them from a command line don't forget to add the .py extension. The version shouldn't make a differnce.
Also, if you could give me the exact error you recieve that would be a great help. Make sure that CMD.exe is in the right directoy. For example when I open CMD it starts out in C:\Documents and Settings\FPHA and if I want to run a python script that I saved in C:\Python as script.py I have to type the following in. cd C:\Python python script.py Hope that helps out! :-D |
This is messed up.
I did the simple program, Hello. - one line, on the editor. When I went to run it, Shell asked to save it, so I saved it hello.py, then shell runs it. I try it at the Command line. Nothing. I go back into the shell, click File, click open, the window opens and my file is not there. Im lost. As for the other things.... Python23 looks like this: C:\Python23 and thats it. Error message after typing : python hello.py File "<stdin>", line 1 python hello.py ^ - (directly under the o) SyntaxError: invalid syntax |
Quote:
To open a command window, click start, RUN and type CMD.exe When that window comes change your directory to whevrever you save your python files (default is the python directory). To change your directoy from inside the command window type cd C:\Python23 (or whatever directory your script might be saved in) and then type python script.py Make sure to try that from inside the command window and not the Python interpreter. |
OMG, lol.
Thank you legacy. Why do we use the CMD.exe ? That's simliar or it IS Dos, no? Dangit I read nowhere on those tutorials that says to open this specific line. Where that error was, you said intepreter... the tutorial says 'if you open the file and its lists 'Python, version, date, system' at the top and then copyright stuff, and has NO drop down menus, and also has the >>> then you're at the command line.' Their tutorial needs to say exactly what you said, 'start, run, cmd.exe'. - would've been a time saver. Sheesh. Ok, now Im able to pull up those .py files correctly. So that I have this correctly, there exists the editor for writing them, the shell for running them, command line for executing them, and what is the intepreter for? I have that one open and I haven't used it yet after a couple of days. Thanks again Legacy |
When the tutorial said command line, it meant the command line persion of Python, not that actual command window. The command line version of python is the interpreter. It runs things on the spot. For example, in the interpreter with the >>> prompt you can type hello world and hit enter and runs it right away (insteaf od saving it and running it with CMD.exe)
:
>>>print "Hello, World." #then you hit enter and seeQuote:
Glad to see you got everyting working out. You'll be coding in no time :D |
can you give us the code you where using it mite help us figure out what could be wrong :)
|
uhm....
yea, it's simple: print "Hello." :lol: The problem was in trying to recall this program on the intepreter by 'hello.py'. I used to type that in and got nothing. But, after Legacies' patience, Im now able to pull up saved programs. ;) |
Quote:
|
| All times are GMT -5. The time now is 11:13 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC