running an existing script

Chris Rebert clp2 at rebertia.com
Wed Jun 22 12:13:48 EDT 2011


On Wed, Jun 22, 2011 at 8:54 AM, Adam Chapman
<adamchapman1985 at hotmail.co.uk> wrote:
<snip>
> I've added the python directories to the environment variable "path"
> in my computer (http://showmedo.com/videotutorials/video?
> name=960000&fromSeriesID=96), which means I can now call python from
> the windows DOS-style command prompt.
>
> My formatting must be wrong when calling the nfold.py script to run.

No, it's a syntax error in the script itself, at least under the
version of Python you're using.

> My connad prompt call and the computer's response look like this:
>
> C:\Users\Adam\Desktop\JBOOST\jboost-2.2\jboost-2.2\scripts>nfold.py
> nfold.py
>  File "C:\Users\Adam\Desktop\JBOOST\jboost-2.2\jboost-2.2\scripts
> \nfold.py", line 13
>    print 'Usage: nfold.py <--booster=boosttype> <--folds=number> [--
> generate | --dir=dir] [--data=file --spec=file] [--rounds=number --
> tree=treetype]'
>
> ^
> SyntaxError: invalid syntax

You're probably running Python 3.x, which changed `print` from a
keyword to just a regular function; hence, `print foo` is illegal, and
one must write `print(foo)` instead.
Based on this, I'd say that nfold.py was written for Python 2.x rather
than Python 3.x; so you'll either need to port it to Python 3.x, or
install Python 2.x and run it under that.

Cheers,
Chris
--
http://rebertia.com



More information about the Python-list mailing list