Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #55553 > unrolled thread
| Started by | Nanderson <mandersonrandersonanderson@gmail.com> |
|---|---|
| First post | 2011-01-31 18:43 -0800 |
| Last post | 2011-01-31 19:08 -0800 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.python
Running python scripts from the command line. Nanderson <mandersonrandersonanderson@gmail.com> - 2011-01-31 18:43 -0800
Re: Running python scripts from the command line. Benjamin Kaplan <benjamin.kaplan@case.edu> - 2011-01-31 21:54 -0500
Re: Running python scripts from the command line. Nanderson <mandersonrandersonanderson@gmail.com> - 2011-01-31 19:08 -0800
| From | Nanderson <mandersonrandersonanderson@gmail.com> |
|---|---|
| Date | 2011-01-31 18:43 -0800 |
| Subject | Running python scripts from the command line. |
| Message-ID | <2e8ce9be-fa71-42ff-a9bf-446bb9ec86dc@l22g2000pre.googlegroups.com> |
I've recently started to program. Python is my first language, so I'm
a complete beginner. I've been trying to call python scripts from the
command line by entering this command into it:
>>>python test.py
But it gives me this error message:
>>>python test.py
File "<stdin>", line 1
python test.py
^
SyntaxError: invalid syntax
I know that test.py exists, and the script is correct (here is is
anyways):
a = 1
if a:
print 'Value of a is', a
I am using python 2.7.1 installed on Windows 7. This seems like
something that should be easy, so I'm sure I'm just missing a very
small problem. Any help is greatly appreciated.
Thanks,
Anderson
[toc] | [next] | [standalone]
| From | Benjamin Kaplan <benjamin.kaplan@case.edu> |
|---|---|
| Date | 2011-01-31 21:54 -0500 |
| Message-ID | <mailman.1527.1296528879.6505.python-list@python.org> |
| In reply to | #55553 |
On Mon, Jan 31, 2011 at 9:43 PM, Nanderson <mandersonrandersonanderson@gmail.com> wrote: > I've recently started to program. Python is my first language, so I'm > a complete beginner. I've been trying to call python scripts from the > command line by entering this command into it: > >>>>python test.py > > But it gives me this error message: > >>>>python test.py > File "<stdin>", line 1 > python test.py > ^ > SyntaxError: invalid syntax > > I know that test.py exists, and the script is correct (here is is > anyways): > > a = 1 > if a: > print 'Value of a is', a > > I am using python 2.7.1 installed on Windows 7. This seems like > something that should be easy, so I'm sure I'm just missing a very > small problem. Any help is greatly appreciated. > > Thanks, > Anderson You're already in Python when you type that. If you want to run a script, you need to call Python from your normal shell, not from inside the Python interpreter. $ python Python 2.6.6 (r266:84292, Jan 10 2011, 20:14:15) [GCC 4.2.1 (Apple Inc. build 5659)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> python Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'python' is not defined >>> exit() $ python test.py Value of a is 1 > -- > http://mail.python.org/mailman/listinfo/python-list >
[toc] | [prev] | [next] | [standalone]
| From | Nanderson <mandersonrandersonanderson@gmail.com> |
|---|---|
| Date | 2011-01-31 19:08 -0800 |
| Message-ID | <736780ab-c840-4f5e-bb4b-5b063771ff4f@w7g2000pre.googlegroups.com> |
| In reply to | #55714 |
On Jan 31, 6:54 pm, Benjamin Kaplan <benjamin.kap...@case.edu> wrote: > On Mon, Jan 31, 2011 at 9:43 PM, Nanderson > > > > > > > > > > <mandersonrandersonander...@gmail.com> wrote: > > I've recently started to program. Python is my first language, so I'm > > a complete beginner. I've been trying to call python scripts from the > > command line by entering this command into it: > > >>>>python test.py > > > But it gives me this error message: > > >>>>python test.py > > File "<stdin>", line 1 > > python test.py > > ^ > > SyntaxError: invalid syntax > > > I know that test.py exists, and the script is correct (here is is > > anyways): > > > a = 1 > > if a: > > print 'Value of a is', a > > > I am using python 2.7.1 installed on Windows 7. This seems like > > something that should be easy, so I'm sure I'm just missing a very > > small problem. Any help is greatly appreciated. > > > Thanks, > > Anderson > > You're already in Python when you type that. If you want to run a > script, you need to call Python from your normal shell, not from > inside the Python interpreter. > > $ python > Python 2.6.6 (r266:84292, Jan 10 2011, 20:14:15) > [GCC 4.2.1 (Apple Inc. build 5659)] on darwin > Type "help", "copyright", "credits" or "license" for more information.>>> python > > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > NameError: name 'python' is not defined>>> exit() > > $ python test.py > Value of a is 1 > > > > > > > > > -- > >http://mail.python.org/mailman/listinfo/python-list Wow, thank you very much for your help. This worked absolutely great. I feel like a huge n00b after that though; it was just so obvious! Anyways, like I said before, thank you very much for your help. Anderson
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web