Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #8102 > unrolled thread

running an existing script

Started byAdam Chapman <adamchapman1985@hotmail.co.uk>
First post2011-06-21 10:45 -0700
Last post2011-06-22 11:50 -0700
Articles 15 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  running an existing script Adam Chapman <adamchapman1985@hotmail.co.uk> - 2011-06-21 10:45 -0700
    Re: running an existing script Ethan Furman <ethan@stoneleaf.us> - 2011-06-21 11:32 -0700
    Re: running an existing script Benjamin Kaplan <benjamin.kaplan@case.edu> - 2011-06-21 11:25 -0700
    Re: running an existing script Ethan Furman <ethan@stoneleaf.us> - 2011-06-21 12:00 -0700
      Re: running an existing script Adam Chapman <adamchapman1985@hotmail.co.uk> - 2011-06-21 13:12 -0700
        Re: running an existing script Adam Chapman <adamchapman1985@hotmail.co.uk> - 2011-06-22 08:54 -0700
          Re: running an existing script Chris Rebert <clp2@rebertia.com> - 2011-06-22 09:13 -0700
          Re: running an existing script Ethan Furman <ethan@stoneleaf.us> - 2011-06-22 09:35 -0700
          Re: running an existing script Adam Chapman <adamchapman1985@hotmail.co.uk> - 2011-06-22 09:15 -0700
            Re: running an existing script Ethan Furman <ethan@stoneleaf.us> - 2011-06-22 09:51 -0700
              Re: running an existing script Adam Chapman <adamchapman1985@hotmail.co.uk> - 2011-06-22 09:51 -0700
                Re: running an existing script Adam Chapman <adamchapman1985@hotmail.co.uk> - 2011-06-22 10:13 -0700
                  Re: running an existing script Ethan Furman <ethan@stoneleaf.us> - 2011-06-22 10:46 -0700
                  Re: running an existing script Adam Chapman <adamchapman1985@hotmail.co.uk> - 2011-06-22 10:54 -0700
                    Re: running an existing script Ethan Furman <ethan@stoneleaf.us> - 2011-06-22 11:50 -0700

#8102 — running an existing script

FromAdam Chapman <adamchapman1985@hotmail.co.uk>
Date2011-06-21 10:45 -0700
Subjectrunning an existing script
Message-ID<e7c49eba-987f-4192-bfb6-afe0b0eddfbd@l6g2000vbn.googlegroups.com>
Hi,

I'm trying to put together a lot of pieces of source code in matlab,
java, perl and python.

Im an expert when it comes to matlab, but novice in all the others
listed above. However, I have integrated the java and perl code so
they can be called from matlab.

I know that there is a toolbox out there called Pymat but i think that
uses 32bit activex so rules my configuration out.

However I think I can hack in to the python command prompt from
matlab.

Basically I just want to run a single script from the python command
window. Once I know how to do that I can be off on my way to perform
the matlab interfacing.

there is an example of the command I need in the python prompt at
http://jboost.sourceforge.net/doc.html#cv .

however, I can't seem to run the python script by typing the command
on that link in the python prompt.

Can I please ask how to set the current duirectory in python?

the script I want to run is in a different directory to the one python
is installed to

[toc] | [next] | [standalone]


#8106

FromEthan Furman <ethan@stoneleaf.us>
Date2011-06-21 11:32 -0700
Message-ID<mailman.232.1308680352.1164.python-list@python.org>
In reply to#8102
Adam Chapman wrote:
> Hi,

Howdy!

> I'm trying to put together a lot of pieces of source code in matlab,
> java, perl and python.

[snippety]

> Basically I just want to run a single script from the python command
> window. Once I know how to do that I can be off on my way to perform
> the matlab interfacing.
> 
> there is an example of the command I need in the python prompt at
> http://jboost.sourceforge.net/doc.html#cv .

That looks like a shell prompt, not a Python prompt

> however, I can't seem to run the python script by typing the command
> on that link in the python prompt.
> 
> Can I please ask how to set the current duirectory in python?

nfold.py is a python script -- you can't just type in the name once 
inside python and have it work.  It would require something like

--> import os
--> os.chdir('path/to/nfold.py') # don't include nfold.py ;)
--> import nfold
--> import sys
--> sys.argv = ["--folds=5", "--data=spambase.data",
... "--spec=spambase.spec", "--rounds=500", "--tree=ADD_ALL",
... "--generate" ]
...
--> nfold.main()  # assuming it has a main function that can be called
                   # in this manner

and that probably won't work.  What you probably want to do is execute 
the command "python /path/to/nfold.py --fold=5 ..." (include the 
nfold.py this time ).  I have no idea how to do that from Matlab.

Good luck!

~Ethan~

[toc] | [prev] | [next] | [standalone]


#8110

FromBenjamin Kaplan <benjamin.kaplan@case.edu>
Date2011-06-21 11:25 -0700
Message-ID<mailman.236.1308680727.1164.python-list@python.org>
In reply to#8102
On Tue, Jun 21, 2011 at 10:45 AM, Adam Chapman
<adamchapman1985@hotmail.co.uk> wrote:
> Hi,
>
> I'm trying to put together a lot of pieces of source code in matlab,
> java, perl and python.
>
> Im an expert when it comes to matlab, but novice in all the others
> listed above. However, I have integrated the java and perl code so
> they can be called from matlab.
>
> I know that there is a toolbox out there called Pymat but i think that
> uses 32bit activex so rules my configuration out.
>
> However I think I can hack in to the python command prompt from
> matlab.
>
> Basically I just want to run a single script from the python command
> window. Once I know how to do that I can be off on my way to perform
> the matlab interfacing.
>
> there is an example of the command I need in the python prompt at
> http://jboost.sourceforge.net/doc.html#cv .
>
> however, I can't seem to run the python script by typing the command
> on that link in the python prompt.
>

That command they show isn't run from a Python shell. It's run from
either a Unix shell (bash and friends) or a Windows command prompt
(cmd). If you want to run a script, you have to give the path to that
script. ./ means the current directory and .. is the parent directory
if you want to give relative paths, or you can just write out the
whole file path.

> Can I please ask how to set the current duirectory in python?
>

os.chdir changes the current directory, but you probably don't need to do that.

> the script I want to run is in a different directory to the one python
> is installed to
> --
> http://mail.python.org/mailman/listinfo/python-list
>

[toc] | [prev] | [next] | [standalone]


#8112

FromEthan Furman <ethan@stoneleaf.us>
Date2011-06-21 12:00 -0700
Message-ID<mailman.238.1308682012.1164.python-list@python.org>
In reply to#8102
Adam Chapman wrote:
> Thanks Ethan
> 
> No way could I have worked that out in my state of stress!
> 
> For your second idea, would I need to type that into the python command 
> line interface (the one that looks like a DOS window?

If you are actually in a python CLI, at the top of that screen does it 
say something like

Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

?

If yes, then what I wrote earlier should actually work (I downloaded 
jBoost and looked at the nfold.py script).  Here it is again:

--> import os
--> os.chdir('path/to/nfold.py') # don't include nfold.py  ;)
--> import nfold
--> import sys
--> sys.argv = ["nfold.py", "--folds=5", "--data=spambase.data",
... "--spec=spambase.spec", "--rounds=500", "--tree=ADD_ALL",
... "--generate" ]
...
--> nfold.main()

I fixed the sys.argv line from last time.

Good luck!

~Ethan~

[toc] | [prev] | [next] | [standalone]


#8127

FromAdam Chapman <adamchapman1985@hotmail.co.uk>
Date2011-06-21 13:12 -0700
Message-ID<44f694fd-c075-41a3-a044-c1b05f2a1463@x38g2000pri.googlegroups.com>
In reply to#8112
On Jun 21, 8:00 pm, Ethan Furman <et...@stoneleaf.us> wrote:
> Adam Chapman wrote:
> > Thanks Ethan
>
> > No way could I have worked that out in my state of stress!
>
> > For your second idea, would I need to type that into the python command
> > line interface (the one that looks like a DOS window?
>
> If you are actually in a python CLI, at the top of that screen does it
> say something like
>
> Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
> (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>
> ?
>
> If yes, then what I wrote earlier should actually work (I downloaded
> jBoost and looked at the nfold.py script).  Here it is again:
>
> --> import os
> --> os.chdir('path/to/nfold.py') # don't include nfold.py  ;)
> --> import nfold
> --> import sys
> --> sys.argv = ["nfold.py", "--folds=5", "--data=spambase.data",
> ... "--spec=spambase.spec", "--rounds=500", "--tree=ADD_ALL",
> ... "--generate" ]
> ...
> --> nfold.main()
>
> I fixed the sys.argv line from last time.
>
> Good luck!
>
> ~Ethan~

Thanks to both of you for your help.

It's getting late here, I'll give it another try tomorrow

[toc] | [prev] | [next] | [standalone]


#8220

FromAdam Chapman <adamchapman1985@hotmail.co.uk>
Date2011-06-22 08:54 -0700
Message-ID<2d53da9c-0a28-4f88-b786-f18a3d0f4f11@f2g2000yqh.googlegroups.com>
In reply to#8127
On Jun 21, 9:12 pm, Adam Chapman <adamchapman1...@hotmail.co.uk>
wrote:
> On Jun 21, 8:00 pm, Ethan Furman <et...@stoneleaf.us> wrote:
>
>
>
>
>
>
>
>
>
> > Adam Chapman wrote:
> > > Thanks Ethan
>
> > > No way could I have worked that out in my state of stress!
>
> > > For your second idea, would I need to type that into the python command
> > > line interface (the one that looks like a DOS window?
>
> > If you are actually in a python CLI, at the top of that screen does it
> > say something like
>
> > Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
> > (Intel)] on win32
> > Type "help", "copyright", "credits" or "license" for more information.
>
> > ?
>
> > If yes, then what I wrote earlier should actually work (I downloaded
> > jBoost and looked at the nfold.py script).  Here it is again:
>
> > --> import os
> > --> os.chdir('path/to/nfold.py') # don't include nfold.py  ;)
> > --> import nfold
> > --> import sys
> > --> sys.argv = ["nfold.py", "--folds=5", "--data=spambase.data",
> > ... "--spec=spambase.spec", "--rounds=500", "--tree=ADD_ALL",
> > ... "--generate" ]
> > ...
> > --> nfold.main()
>
> > I fixed the sys.argv line from last time.
>
> > Good luck!
>
> > ~Ethan~
>
> Thanks to both of you for your help.
>
> It's getting late here, I'll give it another try tomorrow

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.
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


What I dont understand is that some of the parameters in the syntax it
printed back are in <> brackets, and others in [] brackets.

I assume this is something a regular python user could notice straight
away.

Please let me know, I'd be very grateful

[toc] | [prev] | [next] | [standalone]


#8223

FromChris Rebert <clp2@rebertia.com>
Date2011-06-22 09:13 -0700
Message-ID<mailman.288.1308759230.1164.python-list@python.org>
In reply to#8220
On Wed, Jun 22, 2011 at 8:54 AM, Adam Chapman
<adamchapman1985@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

[toc] | [prev] | [next] | [standalone]


#8224

FromEthan Furman <ethan@stoneleaf.us>
Date2011-06-22 09:35 -0700
Message-ID<mailman.289.1308759701.1164.python-list@python.org>
In reply to#8220
Adam Chapman wrote:
> On Jun 21, 9:12 pm, Adam Chapman <adamchapman1...@hotmail.co.uk>
> wrote:
>> On Jun 21, 8:00 pm, Ethan Furman <et...@stoneleaf.us> wrote:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>> Adam Chapman wrote:
>>>> Thanks Ethan
>>>> No way could I have worked that out in my state of stress!
>>>> For your second idea, would I need to type that into the python command
>>>> line interface (the one that looks like a DOS window?
>>> If you are actually in a python CLI, at the top of that screen does it
>>> say something like
>>> Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
>>> (Intel)] on win32
>>> Type "help", "copyright", "credits" or "license" for more information.
>>> ?
>>> If yes, then what I wrote earlier should actually work (I downloaded
>>> jBoost and looked at the nfold.py script).  Here it is again:
>>> --> import os
>>> --> os.chdir('path/to/nfold.py') # don't include nfold.py  ;)
>>> --> import nfold
>>> --> import sys
>>> --> sys.argv = ["nfold.py", "--folds=5", "--data=spambase.data",
>>> ... "--spec=spambase.spec", "--rounds=500", "--tree=ADD_ALL",
>>> ... "--generate" ]
>>> ...
>>> --> nfold.main()
>>> I fixed the sys.argv line from last time.
>>> Good luck!
>>> ~Ethan~
>> Thanks to both of you for your help.
>>
>> It's getting late here, I'll give it another try tomorrow
> 
> 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.
> 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

Looks like you are using Python 3, but nfold is Python 2.  You're being 
tripped up by one of the non-compatible changes -- namely, print is now 
a function and so requires ().


> What I dont understand is that some of the parameters in the syntax it
> printed back are in <> brackets, and others in [] brackets.

Looking at nfold.py it seems that rounds and tree are optional, one of 
generate or dir is required, if dir is not given then data and spec must 
be, and booster and folds are required -- so I'm not really sure why 
they chose the mixture of <> and [].


Also, on the version of jBoost I downloaded there is at least one error 
on nfolds.py on line 134 -- it should be indented one more level.

Hope this helps.

~Ethan~

[toc] | [prev] | [next] | [standalone]


#8225

FromAdam Chapman <adamchapman1985@hotmail.co.uk>
Date2011-06-22 09:15 -0700
Message-ID<58532636-8ddf-44ff-bcc7-1449b6dbdf80@e17g2000prj.googlegroups.com>
In reply to#8220
On Jun 22, 4:54 pm, Adam Chapman <adamchapman1...@hotmail.co.uk>
wrote:
> On Jun 21, 9:12 pm, Adam Chapman <adamchapman1...@hotmail.co.uk>
> wrote:
>
>
>
>
>
>
>
>
>
> > On Jun 21, 8:00 pm, Ethan Furman <et...@stoneleaf.us> wrote:
>
> > > Adam Chapman wrote:
> > > > Thanks Ethan
>
> > > > No way could I have worked that out in my state of stress!
>
> > > > For your second idea, would I need to type that into the python command
> > > > line interface (the one that looks like a DOS window?
>
> > > If you are actually in a python CLI, at the top of that screen does it
> > > say something like
>
> > > Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
> > > (Intel)] on win32
> > > Type "help", "copyright", "credits" or "license" for more information.
>
> > > ?
>
> > > If yes, then what I wrote earlier should actually work (I downloaded
> > > jBoost and looked at the nfold.py script).  Here it is again:
>
> > > --> import os
> > > --> os.chdir('path/to/nfold.py') # don't include nfold.py  ;)
> > > --> import nfold
> > > --> import sys
> > > --> sys.argv = ["nfold.py", "--folds=5", "--data=spambase.data",
> > > ... "--spec=spambase.spec", "--rounds=500", "--tree=ADD_ALL",
> > > ... "--generate" ]
> > > ...
> > > --> nfold.main()
>
> > > I fixed the sys.argv line from last time.
>
> > > Good luck!
>
> > > ~Ethan~
>
> > Thanks to both of you for your help.
>
> > It's getting late here, I'll give it another try tomorrow
>
> 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.
> 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
>
> What I dont understand is that some of the parameters in the syntax it
> printed back are in <> brackets, and others in [] brackets.
>
> I assume this is something a regular python user could notice straight
> away.
>
> Please let me know, I'd be very grateful

I just tried

nfold.py --booster=Adaboost --folds=5 --data=spambase.data --
spec=spambase.spec --rounds=500 --tree=ADD_ALL --generate --dir=C:
\Users\Adam\Desktop\cvdata

in the dos-style command prompt. It didn'g vive a syntax error this
time, it just repeated my command back to me in text. I assume I
called code correctly, but it didn't make a new folder full of data
like it should have.

[toc] | [prev] | [next] | [standalone]


#8226

FromEthan Furman <ethan@stoneleaf.us>
Date2011-06-22 09:51 -0700
Message-ID<mailman.290.1308760634.1164.python-list@python.org>
In reply to#8225
Adam Chapman wrote:
> On Jun 22, 4:54 pm, Adam Chapman <adamchapman1...@hotmail.co.uk>
> wrote:
>> On Jun 21, 9:12 pm, Adam Chapman <adamchapman1...@hotmail.co.uk>
>> wrote:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>> On Jun 21, 8:00 pm, Ethan Furman <et...@stoneleaf.us> wrote:
>>>> Adam Chapman wrote:
>>>>> Thanks Ethan
>>>>> No way could I have worked that out in my state of stress!
>>>>> For your second idea, would I need to type that into the python command
>>>>> line interface (the one that looks like a DOS window?
>>>> If you are actually in a python CLI, at the top of that screen does it
>>>> say something like
>>>> Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
>>>> (Intel)] on win32
>>>> Type "help", "copyright", "credits" or "license" for more information.
>>>> ?
>>>> If yes, then what I wrote earlier should actually work (I downloaded
>>>> jBoost and looked at the nfold.py script).  Here it is again:
>>>> --> import os
>>>> --> os.chdir('path/to/nfold.py') # don't include nfold.py  ;)
>>>> --> import nfold
>>>> --> import sys
>>>> --> sys.argv = ["nfold.py", "--folds=5", "--data=spambase.data",
>>>> ... "--spec=spambase.spec", "--rounds=500", "--tree=ADD_ALL",
>>>> ... "--generate" ]
>>>> ...
>>>> --> nfold.main()
>>>> I fixed the sys.argv line from last time.
>>>> Good luck!
>>>> ~Ethan~
>>> Thanks to both of you for your help.
>>> It's getting late here, I'll give it another try tomorrow
>> 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.
>> 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
>>
>> What I dont understand is that some of the parameters in the syntax it
>> printed back are in <> brackets, and others in [] brackets.
>>
>> I assume this is something a regular python user could notice straight
>> away.
>>
>> Please let me know, I'd be very grateful
> 
> I just tried
> 
> nfold.py --booster=Adaboost --folds=5 --data=spambase.data --
> spec=spambase.spec --rounds=500 --tree=ADD_ALL --generate --dir=C:
> \Users\Adam\Desktop\cvdata
> 
> in the dos-style command prompt. It didn'g vive a syntax error this
> time, it just repeated my command back to me in text. I assume I
> called code correctly, but it didn't make a new folder full of data
> like it should have.
> 

Which version of jBoost, and which version of Python?

~Ethan~

[toc] | [prev] | [next] | [standalone]


#8229

FromAdam Chapman <adamchapman1985@hotmail.co.uk>
Date2011-06-22 09:51 -0700
Message-ID<7acdb2ca-a5a9-4c20-ade0-c598bb0b5bae@c41g2000yqm.googlegroups.com>
In reply to#8226
On Jun 22, 5:51 pm, Ethan Furman <et...@stoneleaf.us> wrote:
> Adam Chapman wrote:
> > On Jun 22, 4:54 pm, Adam Chapman <adamchapman1...@hotmail.co.uk>
> > wrote:
> >> On Jun 21, 9:12 pm, Adam Chapman <adamchapman1...@hotmail.co.uk>
> >> wrote:
>
> >>> On Jun 21, 8:00 pm, Ethan Furman <et...@stoneleaf.us> wrote:
> >>>> Adam Chapman wrote:
> >>>>> Thanks Ethan
> >>>>> No way could I have worked that out in my state of stress!
> >>>>> For your second idea, would I need to type that into the python command
> >>>>> line interface (the one that looks like a DOS window?
> >>>> If you are actually in a python CLI, at the top of that screen does it
> >>>> say something like
> >>>> Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
> >>>> (Intel)] on win32
> >>>> Type "help", "copyright", "credits" or "license" for more information.
> >>>> ?
> >>>> If yes, then what I wrote earlier should actually work (I downloaded
> >>>> jBoost and looked at the nfold.py script).  Here it is again:
> >>>> --> import os
> >>>> --> os.chdir('path/to/nfold.py') # don't include nfold.py  ;)
> >>>> --> import nfold
> >>>> --> import sys
> >>>> --> sys.argv = ["nfold.py", "--folds=5", "--data=spambase.data",
> >>>> ... "--spec=spambase.spec", "--rounds=500", "--tree=ADD_ALL",
> >>>> ... "--generate" ]
> >>>> ...
> >>>> --> nfold.main()
> >>>> I fixed the sys.argv line from last time.
> >>>> Good luck!
> >>>> ~Ethan~
> >>> Thanks to both of you for your help.
> >>> It's getting late here, I'll give it another try tomorrow
> >> 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.
> >> 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
>
> >> What I dont understand is that some of the parameters in the syntax it
> >> printed back are in <> brackets, and others in [] brackets.
>
> >> I assume this is something a regular python user could notice straight
> >> away.
>
> >> Please let me know, I'd be very grateful
>
> > I just tried
>
> > nfold.py --booster=Adaboost --folds=5 --data=spambase.data --
> > spec=spambase.spec --rounds=500 --tree=ADD_ALL --generate --dir=C:
> > \Users\Adam\Desktop\cvdata
>
> > in the dos-style command prompt. It didn'g vive a syntax error this
> > time, it just repeated my command back to me in text. I assume I
> > called code correctly, but it didn't make a new folder full of data
> > like it should have.
>
> Which version of jBoost, and which version of Python?
>
> ~Ethan~

jboost 2.2, python 2.7

somehow I've just managed to delete all of the code in nfold.py, now
downloading it again...

[toc] | [prev] | [next] | [standalone]


#8230

FromAdam Chapman <adamchapman1985@hotmail.co.uk>
Date2011-06-22 10:13 -0700
Message-ID<413b6a24-1b7c-4ae9-aef7-1533df92d1d7@v10g2000yqn.googlegroups.com>
In reply to#8229
On Jun 22, 5:51 pm, Adam Chapman <adamchapman1...@hotmail.co.uk>
wrote:
> On Jun 22, 5:51 pm, Ethan Furman <et...@stoneleaf.us> wrote:
>
>
>
>
>
>
>
>
>
> > Adam Chapman wrote:
> > > On Jun 22, 4:54 pm, Adam Chapman <adamchapman1...@hotmail.co.uk>
> > > wrote:
> > >> On Jun 21, 9:12 pm, Adam Chapman <adamchapman1...@hotmail.co.uk>
> > >> wrote:
>
> > >>> On Jun 21, 8:00 pm, Ethan Furman <et...@stoneleaf.us> wrote:
> > >>>> Adam Chapman wrote:
> > >>>>> Thanks Ethan
> > >>>>> No way could I have worked that out in my state of stress!
> > >>>>> For your second idea, would I need to type that into the python command
> > >>>>> line interface (the one that looks like a DOS window?
> > >>>> If you are actually in a python CLI, at the top of that screen does it
> > >>>> say something like
> > >>>> Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
> > >>>> (Intel)] on win32
> > >>>> Type "help", "copyright", "credits" or "license" for more information.
> > >>>> ?
> > >>>> If yes, then what I wrote earlier should actually work (I downloaded
> > >>>> jBoost and looked at the nfold.py script).  Here it is again:
> > >>>> --> import os
> > >>>> --> os.chdir('path/to/nfold.py') # don't include nfold.py  ;)
> > >>>> --> import nfold
> > >>>> --> import sys
> > >>>> --> sys.argv = ["nfold.py", "--folds=5", "--data=spambase.data",
> > >>>> ... "--spec=spambase.spec", "--rounds=500", "--tree=ADD_ALL",
> > >>>> ... "--generate" ]
> > >>>> ...
> > >>>> --> nfold.main()
> > >>>> I fixed the sys.argv line from last time.
> > >>>> Good luck!
> > >>>> ~Ethan~
> > >>> Thanks to both of you for your help.
> > >>> It's getting late here, I'll give it another try tomorrow
> > >> 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.
> > >> 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
>
> > >> What I dont understand is that some of the parameters in the syntax it
> > >> printed back are in <> brackets, and others in [] brackets.
>
> > >> I assume this is something a regular python user could notice straight
> > >> away.
>
> > >> Please let me know, I'd be very grateful
>
> > > I just tried
>
> > > nfold.py --booster=Adaboost --folds=5 --data=spambase.data --
> > > spec=spambase.spec --rounds=500 --tree=ADD_ALL --generate --dir=C:
> > > \Users\Adam\Desktop\cvdata
>
> > > in the dos-style command prompt. It didn'g vive a syntax error this
> > > time, it just repeated my command back to me in text. I assume I
> > > called code correctly, but it didn't make a new folder full of data
> > > like it should have.
>
> > Which version of jBoost, and which version of Python?
>
> > ~Ethan~
>
> jboost 2.2, python 2.7
>
> somehow I've just managed to delete all of the code in nfold.py, now
> downloading it again...

Thanks a lot, must be getting close now...
I changed the indentation one lines 136-168, and put in the command
window:

nfold.py --booster=Adaboost --folds=5 --data=spambase.data --
spec=spambase.spec --rounds=500 --tree=ADD_ALL --generate

no syntax errors this time, it just said:
nfold.py: Your CLASSPATH is not set. You must place jboost.jar in your
CLASSPATH.

is that the chdir() command in python? and can I somehow set that in
the dos command window?




[toc] | [prev] | [next] | [standalone]


#8232

FromEthan Furman <ethan@stoneleaf.us>
Date2011-06-22 10:46 -0700
Message-ID<mailman.291.1308763989.1164.python-list@python.org>
In reply to#8230
Adam Chapman wrote:
> Thanks a lot, must be getting close now...
> I changed the indentation one lines 136-168, and put in the command
> window:
> 
> nfold.py --booster=Adaboost --folds=5 --data=spambase.data --
> spec=spambase.spec --rounds=500 --tree=ADD_ALL --generate
> 
> no syntax errors this time, it just said:
> nfold.py: Your CLASSPATH is not set. You must place jboost.jar in your
> CLASSPATH.
> 
> is that the chdir() command in python? and can I somehow set that in
> the dos command window?

CLASSPATH is an environment variable, jboost.jar is a java file (which 
I'm sure you know ;) -- so make sure CLASSPATH is set appropriately for 
your system (e.g. 'set CLASSPATH=c:\java\source'), and jboost.jar is 
whereever CLASSPATH points to.  (I'm not a Java fan, so can't provide 
much help in this area.)

~Ethan~

[toc] | [prev] | [next] | [standalone]


#8237

FromAdam Chapman <adamchapman1985@hotmail.co.uk>
Date2011-06-22 10:54 -0700
Message-ID<ab9c12eb-89e9-4c8a-bb8b-7790805d2c50@j31g2000yqe.googlegroups.com>
In reply to#8230
On Jun 22, 6:13 pm, Adam Chapman <adamchapman1...@hotmail.co.uk>
wrote:
> On Jun 22, 5:51 pm, Adam Chapman <adamchapman1...@hotmail.co.uk>
> wrote:
>
>
>
>
>
>
>
>
>
> > On Jun 22, 5:51 pm, Ethan Furman <et...@stoneleaf.us> wrote:
>
> > > Adam Chapman wrote:
> > > > On Jun 22, 4:54 pm, Adam Chapman <adamchapman1...@hotmail.co.uk>
> > > > wrote:
> > > >> On Jun 21, 9:12 pm, Adam Chapman <adamchapman1...@hotmail.co.uk>
> > > >> wrote:
>
> > > >>> On Jun 21, 8:00 pm, Ethan Furman <et...@stoneleaf.us> wrote:
> > > >>>> Adam Chapman wrote:
> > > >>>>> Thanks Ethan
> > > >>>>> No way could I have worked that out in my state of stress!
> > > >>>>> For your second idea, would I need to type that into the python command
> > > >>>>> line interface (the one that looks like a DOS window?
> > > >>>> If you are actually in a python CLI, at the top of that screen does it
> > > >>>> say something like
> > > >>>> Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
> > > >>>> (Intel)] on win32
> > > >>>> Type "help", "copyright", "credits" or "license" for more information.
> > > >>>> ?
> > > >>>> If yes, then what I wrote earlier should actually work (I downloaded
> > > >>>> jBoost and looked at the nfold.py script).  Here it is again:
> > > >>>> --> import os
> > > >>>> --> os.chdir('path/to/nfold.py') # don't include nfold.py  ;)
> > > >>>> --> import nfold
> > > >>>> --> import sys
> > > >>>> --> sys.argv = ["nfold.py", "--folds=5", "--data=spambase.data",
> > > >>>> ... "--spec=spambase.spec", "--rounds=500", "--tree=ADD_ALL",
> > > >>>> ... "--generate" ]
> > > >>>> ...
> > > >>>> --> nfold.main()
> > > >>>> I fixed the sys.argv line from last time.
> > > >>>> Good luck!
> > > >>>> ~Ethan~
> > > >>> Thanks to both of you for your help.
> > > >>> It's getting late here, I'll give it another try tomorrow
> > > >> 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.
> > > >> 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
>
> > > >> What I dont understand is that some of the parameters in the syntax it
> > > >> printed back are in <> brackets, and others in [] brackets.
>
> > > >> I assume this is something a regular python user could notice straight
> > > >> away.
>
> > > >> Please let me know, I'd be very grateful
>
> > > > I just tried
>
> > > > nfold.py --booster=Adaboost --folds=5 --data=spambase.data --
> > > > spec=spambase.spec --rounds=500 --tree=ADD_ALL --generate --dir=C:
> > > > \Users\Adam\Desktop\cvdata
>
> > > > in the dos-style command prompt. It didn'g vive a syntax error this
> > > > time, it just repeated my command back to me in text. I assume I
> > > > called code correctly, but it didn't make a new folder full of data
> > > > like it should have.
>
> > > Which version of jBoost, and which version of Python?
>
> > > ~Ethan~
>
> > jboost 2.2, python 2.7
>
> > somehow I've just managed to delete all of the code in nfold.py, now
> > downloading it again...
>
> Thanks a lot, must be getting close now...
> I changed the indentation one lines 136-168, and put in the command
> window:
>
> nfold.py --booster=Adaboost --folds=5 --data=spambase.data --
> spec=spambase.spec --rounds=500 --tree=ADD_ALL --generate
>
> no syntax errors this time, it just said:
> nfold.py: Your CLASSPATH is not set. You must place jboost.jar in your
> CLASSPATH.
>
> is that the chdir() command in python? and can I somehow set that in
> the dos command window?

Thanks again Ethan, It did begin to run nfold.py this time, after I
added the environment variable "CLASSPATH" to my system. It threw back
a java error, but I guess this isn;t the right place to be asking
about that

C:\Users\Adam\Desktop\JBOOST\jboost-2.2\jboost-2.2\scripts>nfold.py --
booster=Adaboost --folds=5 --data=spambase.data --spec=spambase.spec --
rounds=500 --tree=ADD_ALL --generate
nfold.py --booster=Adaboost --folds=5 --data=spambase.data --
spec=spambase.spec --rounds=500 --tree=ADD_ALL --generate
java.lang.NoClassDefFoundError: jboost/controller/Controller
Caused by: java.lang.ClassNotFoundException:
jboost.controller.Controller
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: jboost.controller.Controller.  Program
will exit.
Exception in thread "main" k: 0 start:0 end:920
k: 1 start:920 end:1840
k: 2 start:1840 end:2760
k: 3 start:2760 end:3680
k: 4 start:3680 end:4600
*=---------------------------------------------------------------------
=-*
* Fold 0     |
*============
java -Xmx1000M -cp C:\Users\Adam\\Desktop\JBOOST
\jboost-2.2\jboost-2.2\dist jboost.controller.Controller -b Adaboost -
p 3 -a -1 -S trial0 -n trial.spec -ATreeType ADD_ALL -numRounds 500

[toc] | [prev] | [next] | [standalone]


#8238

FromEthan Furman <ethan@stoneleaf.us>
Date2011-06-22 11:50 -0700
Message-ID<mailman.293.1308767801.1164.python-list@python.org>
In reply to#8237
Adam Chapman wrote:
> Thanks again Ethan, It did begin to run nfold.py this time, after I
> added the environment variable "CLASSPATH" to my system. It threw back
> a java error, but I guess this isn;t the right place to be asking
> about that
> 
> C:\Users\Adam\Desktop\JBOOST\jboost-2.2\jboost-2.2\scripts>nfold.py --
> booster=Adaboost --folds=5 --data=spambase.data --spec=spambase.spec --
> rounds=500 --tree=ADD_ALL --generate
> nfold.py --booster=Adaboost --folds=5 --data=spambase.data --
> spec=spambase.spec --rounds=500 --tree=ADD_ALL --generate
> java.lang.NoClassDefFoundError: jboost/controller/Controller
> Caused by: java.lang.ClassNotFoundException:
> jboost.controller.Controller
> 	at java.net.URLClassLoader$1.run(Unknown Source)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.net.URLClassLoader.findClass(Unknown Source)
> 	at java.lang.ClassLoader.loadClass(Unknown Source)
> 	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> 	at java.lang.ClassLoader.loadClass(Unknown Source)
> Could not find the main class: jboost.controller.Controller.  Program
> will exit.
> Exception in thread "main" k: 0 start:0 end:920


Looking at the batch file I see a line that modifies the CLASSPATH, so 
try this before you run nfold.py (cut across two lines, but it's really 
just one):
set CLASSPATH= 
%CLASSPATH%;../dist/jboost.jar;../lib/jfreechart-1.0.10.jar;../lib/jcommon-1.0.8.jar 



Good luck!

~Ethan~

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web