Re: How to configure Python in Windows



On 2月28日, 下午6时52分, Larry Bates <larry.ba...@xxxxxxxxxxx> wrote:
cosmo_gene...@xxxxxxxxx wrote:
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

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!


.



Relevant Pages

  • Re: How do I add users using Python scripts on a Linux machine
    ... supply his own `python interpreter' in his PATH.) ... So when a the kernel detects that an executable file is actually a script, ...
    (comp.lang.python)
  • Re: no module named error
    ... I was at the python command line '>>>' and I did the following command. ... But I'm not quite sure how to fix it in my script or env. ... invoke the Python interpreter. ... Unicode strings are no longer ignored. ...
    (comp.lang.python)
  • Re: Pyhton Interpreter Startup time
    ... Pre-compile the script. ... You can compile the script without running it by using the py_compile ... You can then run the compiled version using 'python my_script.pyc' ... py2exe just embeds the Python interpreter in the .exe. ...
    (comp.lang.python)
  • Re: Problem with py2exe-frozen CGIHttpServer-based script
    ... It tries to start 'sys.executable' with the python cgi script. ... sys.executable is the Python interpreter, but for a py2exe'd script this ... frozen script work (although then the Python installation is required ...
    (comp.lang.python)
  • Re: Now what!?
    ... I'm following A Byte of Python and into the while loops chap. ... while.py to a file and give 777 perms. ... as a standalone script. ... ./while: line 9: syntax error near unexpected token (' ...
    (comp.lang.python)