Weka python wrapper Loader
Question: I've installed weka python wrapper on Mc Os X 10.9.4. And I tried running the
sample code:

    
    
    import weka.core.jvm as jvm
    jvm.start()
    
    from weka.core.converters import Loader
    l = Loader("weka.core.converters.ArffLoader")
    d = l.load_file("X.arff")
    
    d.set_class_index(d.num_attributes() - 1)
    print(d)
    

and I receive the following error:

    
    
    Failed to get class weka/core/converters/ArffLoader
    Exception in thread "Thread-2" java.lang.NoClassDefFoundError: weka/core/converters/ArffLoader
    Failed to instantiate weka.core.converters.ArffLoader/weka/core/converters/ArffLoader: weka/core/converters/ArffLoader
    Caused by: java.lang.ClassNotFoundException: weka.core.converters.ArffLoader
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    Traceback (most recent call last):
      File "/Users/hani/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2883, in run_code
        exec(code_obj, self.user_global_ns, self.user_ns)
      File "<ipython-input-5-d835d9d560d2>", line 2, in <module>
        l = Loader("weka.core.converters.ArffLoader")
      File "/Users/hani/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/python_weka_wrapper-0.1.10-py2.7.egg/weka/core/converters.py", line 40, in __init__
        self.enforce_type(jobject, "weka.core.converters.Loader")
      File "/Users/hani/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/python_weka_wrapper-0.1.10-py2.7.egg/weka/core/classes.py", line 113, in enforce_type
        raise TypeError("Object does not implement or subclass " + intf_or_class + "!")
    TypeError: Object does not implement or subclass weka.core.converters.Loader!
    

After some tinkering I realized that setting the working directory to the
python-weka-wrapper folder using os.chdir remedies the problem in some
environments but not all of them (e.g. pycharm is not fixed using this trick).
Any ideas how I can fix this issue?


Answer: Apparently, calling jvm with the paths to weka jar files would solve the
problem:

    
    
    jvm.start(class_path=['/some/where/python-weka-wrapper.jar', 
    '/some/where/weka.jar'])
    

Thanks to Peter Reutemann for this reply.

