Help! Can't get program to run.

S

seanm.py

I think this is maybe the most basic problem possible, but I can't get
even the most basic Python to run on OS X using Terminal or IDLE. I
used the IDLE editor to create a file with one line of code

print 'text string'

and I saved the file as module1.py. When using terminal I entered
"python" to load the interpreter or whatever and then tried

python module1.py

but I got an error message. I've tried using the file path instead of
module1.py and that didn't work either. I've tried moving the file to
different places, my desktop, hard drive, etc., and none of that
worked either. In IDLE I tried similar things and only got error
messages there too.

Needless to say this is a frustrating start to learning this langauge.
I'd really appreciate any help getting this to work, so I can move on
the actual language. Thanks so much.
 
D

Diez B. Roggisch

I think this is maybe the most basic problem possible, but I can't get
even the most basic Python to run on OS X using Terminal or IDLE. I
used the IDLE editor to create a file with one line of code

print 'text string'

and I saved the file as module1.py. When using terminal I entered
"python" to load the interpreter or whatever and then tried

python module1.py

but I got an error message. I've tried using the file path instead of
module1.py and that didn't work either. I've tried moving the file to
different places, my desktop, hard drive, etc., and none of that
worked either. In IDLE I tried similar things and only got error
messages there too.

Needless to say this is a frustrating start to learning this langauge.
I'd really appreciate any help getting this to work, so I can move on
the actual language. Thanks so much.

It would have helped if you had given us the *actual* error-message.


From what little information you give, it appears as if you do
something very basic wrong - instead of doing

$ python
(where $ is the shell/terminal and >>> the python-prompt)

you either do

$ python
or

$ python mymodule.py

to execute mymodule directly.

Diez
 
N

Ned Deily

It would have helped if you had given us the *actual* error-message.
From what little information you give, it appears as if you do
something very basic wrong - instead of doing
$ python
(where $ is the shell/terminal and >>> the python-prompt)
you either do
$ python
or
$ python mymodule.py
to execute mymodule directly.

And from within OS X IDLE itself, if you create or open the file
mymodule.py, it will be in a separate window and, as long as that window
is selected, you can run the file directly within IDLE by selecting "Run
Module" from the "Run" menu. So, no need to use the Terminal if you
don't want to.
 
S

seanm.py

And from within OS X IDLE itself, if you create or open the file
mymodule.py, it will be in a separate window and, as long as that window
is selected, you can run the file directly within IDLE by selecting "Run
Module" from the "Run" menu.   So, no need to use the Terminal if you
don't want to.

Thank you for both for the help. I still cannot get the program to run
though. Below I've copied my commands and the error messages for you
(in IDLE then Terminal):

IDLE 2.6.2SyntaxError: invalid syntax

and

sean-marimpietris-computer:~ seanmarimpietri$ python
Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information. File "<stdin>", line 1
python module1.py
^
SyntaxError: invalid syntax



Again, any help would be appreciated. Thanks.
 
A

Arnaud Delobelle

sean-marimpietris-computer:~ seanmarimpietri$ python
Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.File "<stdin>", line 1
python module1.py
^
SyntaxError: invalid syntax



Again, any help would be appreciated. Thanks.

From Terminal.app, this should work:

sean-marimpietris-computer:~ seanmarimpietri$ python module1.py

Assuming that your module1.py file is in /Users/seanmarimpietri/
 
S

seanm.py

sean-marimpietris-computer:~ seanmarimpietri$ python
Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
python module1.py
  File "<stdin>", line 1
    python module1.py
                 ^
SyntaxError: invalid syntax
Again, any help would be appreciated. Thanks.

From Terminal.app, this should work:

sean-marimpietris-computer:~ seanmarimpietri$ python module1.py

Assuming that your module1.py file is in /Users/seanmarimpietri/

Awesome. Thank you, Arnaud. I moved the file to that folder, and I got
it to work in Terminal. However, I still can't get it to run using
IDLE. Any idea why that might be? Thanks again. -Sean
 
N

Ned Deily

Thank you for both for the help. I still cannot get the program to run
though. Below I've copied my commands and the error messages for you
(in IDLE then Terminal):

IDLE 2.6.2
SyntaxError: invalid syntax

The default IDLE window is a python shell window. That is, you are
already "inside" the python interpreter, the same as if you typed just
"python", with no file name, in the Terminal window. You can use that
to execute python statements and introspect objects, among other things.
Try it.

But, back in IDLE, ignore that window for the moment and use the Open
command in the File Menu to select and open your file module1.py from
whatever directory it is in. A new window should open with the contents
of that file. With that window selected (click on it, if necessary),
there should be a "Run" option in the Menu bar and under it will be a
"Run Script" option that will cause the script to run and the output to
appear in the shell window. You can then explore the other options
available in IDLE for debugging, etc.
 
S

seanm.py

The default IDLE window is a python shell window.  That is, you are
already "inside" the python interpreter, the same as if you typed just
"python", with no file name, in the Terminal window.  You can use that
to execute python statements and introspect objects, among other things.  
Try it.

But, back in IDLE, ignore that window for the moment and use the Open
command in the File Menu to select and open your file module1.py from
whatever directory it is in.  A new window should open with the contents
of that file.  With that window selected (click on it, if necessary),
there should be a "Run" option in the Menu bar and under it will be a
"Run Script" option that will cause the script to run and the output to
appear in the shell window.  You can then explore the other options
available in IDLE for debugging, etc.

Awesome. I think that clears it up (at least enough for now). Thank
you both very much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top