How to configure Python in Windows

C

cosmo_general

Hi Folks,

I just downloaded precompiled Python for Windows, and it runs. Now I
have got the command line coding. However, I can't run my python
scripts. My python script, foo.py, is located in C:\\....\pydir, and I
have set the python interpreter on the directory. When I run
os.listdir(), I found my script of foo.py is right in the pydir. But,
when I tried to run command-line python foo.py, to compile it, I got
"Syntax error: invalid syntax". I guess the interpreter did not find
my script foo.py. In the past, I worked python on unix/linux, and I
knew how set the path, and I ran my python scripts smoothly. I wonder
anybody can help me to configure the python interpreter? Thanks!

Muddy Coder
 
L

Larry Bates

Hi Folks,

I just downloaded precompiled Python for Windows, and it runs. Now I
have got the command line coding. However, I can't run my python
scripts. My python script, foo.py, is located in C:\\....\pydir, and I
have set the python interpreter on the directory. When I run
os.listdir(), I found my script of foo.py is right in the pydir. But,
when I tried to run command-line python foo.py, to compile it, I got
"Syntax error: invalid syntax". I guess the interpreter did not find
my script foo.py. In the past, I worked python on unix/linux, and I
knew how set the path, and I ran my python scripts smoothly. I wonder
anybody can help me to configure the python interpreter? Thanks!

Muddy Coder

Syntax error is not give if interpreter can't find a script. You should post
full tracebacks on this newsgroup so we can help. It is more likely that you
actually have a syntax error in foo.py.

-Larry
 
C

cosmo_general

Syntax error is not give if interpreter can't find a script. You should post
full tracebacks on this newsgroup so we can help. It is more likely that you
actually have a syntax error in foo.py.

-Larry

Hi Larry,

Thanks for help. I retried to run the script. My script is as simple
as:
import os

dir=os.getcwd()

print "cwd is",dir

The results are:

1) If I edit it with a text editor, and try to compile at Python
shell, the error message is: SyntaxError: invalid syntax
2) If I run the module by pressing F5, it ran, and printed out the
directory name

Can you figure it out? Thanks!
 
D

Dennis Lee Bieber

The results are:

1) If I edit it with a text editor, and try to compile at Python
shell, the error message is: SyntaxError: invalid syntax
2) If I run the module by pressing F5, it ran, and printed out the
directory name

Can you figure it out? Thanks!
Must be a new class starting, two people in one day...

The interactive python prompt is just that, and interactive prompt
for python source lines.

If you have a file containing python code, you execute it from the
OS command prompt...

c:\tmp> python my_file.py
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
S

Steve Holden

Hi Folks,

I just downloaded precompiled Python for Windows, and it runs. Now I
have got the command line coding. However, I can't run my python
scripts. My python script, foo.py, is located in C:\\....\pydir, and I
have set the python interpreter on the directory. When I run
os.listdir(), I found my script of foo.py is right in the pydir. But,
when I tried to run command-line python foo.py, to compile it, I got
"Syntax error: invalid syntax". I guess the interpreter did not find
my script foo.py. In the past, I worked python on unix/linux, and I
knew how set the path, and I ran my python scripts smoothly. I wonder
anybody can help me to configure the python interpreter? Thanks!
http://www.python.org/doc/faq/windows/

regards
Steve
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top