Installing packages when using WinPython

742 views
Skip to first unread message

Dario Peralta

unread,
Jun 9, 2015, 4:24:06 PM6/9/15
to python-we...@googlegroups.com
Hi,

I've got python-weka-wrapper working on WinPython-64bit-2.7.9.2. However, I can't seem to get LibSVM to work even though it's in the list generated by calling packages.installed_packages().

When I try to create a LibSVM classifier a get the following error:

Failed to get class weka/classifiers/functions/LibSVM
Failed to instantiate weka.classifiers.functions.LibSVM/weka/classifiers/functions/LibSVM: weka/classifiers/functions/LibSVM

I'm using Weka 3.7.12. I installed LibSVM through Weka's GUI.

I've tried:

- Checking that weka.jar is in the system path (it is)
- Manually adding the folder with the extra packages I've installed in Weka by passing the appropiated path to the jvm.start's class_path parameter (... \wekafiles\packages\*.*)
- Calling jvm.start with packages=True.
- Manually copying the LibSVM jar to path within WinPython (...\WinPython-64bit-2.7.9.2\python-2.7.9.amd64\Lib\site-packages\weka\lib)

I feel it's just a matter of telling python-weka-wrapper (and javabridge) where to find the right weka files. I just can't figure out how to do that.

Regards,
Dario.


Peter Reutemann

unread,
Jun 9, 2015, 5:58:56 PM6/9/15
to python-weka-wrapper
Sorry, but I can't replicate this issue. I just installed python-weka-wrapper on a clean Win7 32 bit installation (inside virtualbox), with Java 8 (update 45). I used the weka.jar that comes with python-weka-wrapper (on my machine, located in "C:\Python27\Lib\site-packages\weka\lib") to fire up the package manager and install LibSVM 1.0.6. After that, I opened a command prompt and did the following:

- start up the JVM with installed packages

>>> import weka.core.jvm as jvm
>>> jvm.start(packages=True)
DEBUG:weka.core.jvm:Adding bundled jars
DEBUG:weka.core.jvm:Adding Weka packages
DEBUG:weka.core.jvm:package_dir=C:\Users\fracpete\wekafiles\packages
DEBUG:weka.core.jvm:  directory=C:\Users\fracpete\wekafiles\packages\LibSVM
DEBUG:weka.core.jvm:Classpath=['C:\\Python27\\lib\\site-packages\\javabridge\\jars\\rhino-1.7R4.jar', 'C:\\Python27\\lib\\site-packages\\javabridge\\jars\\runnablequeue.jar', 'C:\\Python27\\lib\\site-packages\\javabridge\\jars\\cpython.jar', 'C:\\Python27\\lib\\site-packages\\weka\\lib\\python-weka-wrapper.jar', 'C:\\Python27\\lib\\site-packages\\weka\\lib\\weka.jar', 'C:\\Users\\fracpete\\wekafiles\\packages\\LibSVM\\lib\\libsvm.jar', 'C:\\Users\\fracpete\\wekafiles\\packages\\LibSVM\\LibSVM.jar']
DEBUG:weka.core.jvm:MaxHeapSize=default
DEBUG:javabridge.jutil:Creating JVM object
DEBUG:javabridge.jutil:Signalling caller

- instantiating libsvm classifier

>>> from weka.classifiers import Classifier
>>> cls = Classifier(classname="weka.classifiers.functions.LibSVM")

- loading a dataset

>>> import weka.core.converters as converters
>>> from weka.core.converters import Loader
>>> loader = Loader(classname="weka.core.converters.ArffLoader")
>>> data = loader.load_file("C:\\Users\\fracpete\\Downloads\\iris.arff")
>>> data.class_is_last()

- building the classifier

>>> cls.build_classifier(data)
*
optimization finished, #iter = 46
nu = 0.04649643899269115
obj = -2.4034163421252717, rho = 0.03985691051205832
nSV = 11, nBSV = 2
*
optimization finished, #iter = 30
nu = 0.038905109445750645
obj = -1.9451468376629963, rho = 0.1677745320943027
nSV = 10, nBSV = 0
*
optimization finished, #iter = 36
nu = 0.2935651466869792
obj = -21.37749109099391, rho = 0.143704687543137
nSV = 33, nBSV = 26
Total nSV = 45

Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 858-5174
http://www.cms.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/

Dario Peralta

unread,
Jun 12, 2015, 1:35:58 PM6/12/15
to python-we...@googlegroups.com, frac...@waikato.ac.nz
Thanks for the quick reply! :)


I think it might have something to do with that. Because WinPython doesn't "install" Python on the local Windows. It is self-contained.

I tried running the package manager from the weka jar inside the WinPython installation by doing: 

C:\WinPython-64bit-2.7.9.2\python-2.7.9.amd64\Lib\site-packages\weka\lib>java -jar weka.jar weka.core.WekaPackageManager

But that showed LibSVM as already installed.

When I tried running jvm.start(packages=True) I got an error that said the path:

C:\WinPython-64bit-2.7.9.2\settings\wekafiles\packages\*.*

couldn't be found.

So, I just copied the files from their location under my windows user C:\Users\Dario\wekafiles. This got things running.

It seems like a weird workaround, like for somethings things are being found in their general windows user based location and others have to be under the WinPython installation. And will probably mean that I'd have to keep these two folders synced if I install new packages.

Regards,
Dario.

Peter Reutemann

unread,
Jun 13, 2015, 5:20:48 PM6/13/15
to python-weka-wrapper
Hi Dario

> I think it might have something to do with that. Because WinPython doesn't
> "install" Python on the local Windows. It is self-contained.
>
> I tried running the package manager from the weka jar inside the WinPython
> installation by doing:
>
> C:\WinPython-64bit-2.7.9.2\python-2.7.9.amd64\Lib\site-packages\weka\lib>java
> -jar weka.jar weka.core.WekaPackageManager
>
> But that showed LibSVM as already installed.
>
> When I tried running jvm.start(packages=True) I got an error that said the
> path:
>
> C:\WinPython-64bit-2.7.9.2\settings\wekafiles\packages\*.*
>
> couldn't be found.

Looks like WinPython changes the behavior of expanding "~", using its
own top-level directory.

I've just committed some changes that allow you to specify an
alternative location for the Weka home directory:
https://github.com/fracpete/python-weka-wrapper/issues/34

That should solve your problem.

Thanks for using the wrapper!

Dario Peralta

unread,
Jun 15, 2015, 5:11:25 AM6/15/15
to python-we...@googlegroups.com, frac...@waikato.ac.nz
Thank you so much! I'll try installing this new release and report back.

Peter Reutemann

unread,
Jun 15, 2015, 5:14:12 AM6/15/15
to python-weka-wrapper

Not yet a release, you'll have to install from source.

Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 858-5174
http://www.cms.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz

--
You received this message because you are subscribed to the Google Groups "python-weka-wrapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-weka-wra...@googlegroups.com.
To post to this group, send email to python-we...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python-weka-wrapper/33078456-0718-4fde-8644-8464f2b918af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dario Peralta

unread,
Jun 15, 2015, 6:12:44 AM6/15/15
to python-we...@googlegroups.com, frac...@waikato.ac.nz
Thank you very much!

Getting it working was a simple matter after you made this change.

Here's what I did (in case anyone has a similar problem in the future):

1. Started from a clean install of WinPython
2. Installed javabridge following the instructions given by the WinPython team (https://github.com/winpython/winpython/wiki/Installing-Additional-Packages)
3. Downloaded python-weka-wrapper from github
4. Used WinPython Package Manager to install directly from the source zip file
5. Passed the path to the Weka home dir as the value for the packages parameter of jvm.start()

Best regards,
Darío.
To unsubscribe from this group and stop receiving emails from it, send an email to python-weka-wrapper+unsub...@googlegroups.com.

Peter Reutemann

unread,
Jun 15, 2015, 2:55:20 PM6/15/15
to python-weka-wrapper


> Getting it working was a simple matter after you made this change.
>
> Here's what I did (in case anyone has a similar problem in the future):
>
> 1. Started from a clean install of WinPython
> 2. Installed javabridge following the instructions given by the WinPython team (https://github.com/winpython/winpython/wiki/Installing-Additional-Packages)
> 3. Downloaded python-weka-wrapper from github
> 4. Used WinPython Package Manager to install directly from the source zip file
> 5. Passed the path to the Weka home dir as the value for the packages parameter of jvm.start()

Excellent!

Cheers, Peter

Reply all
Reply to author
Forward
0 new messages