Weka Installation Problem on the Colab

621 views
Skip to first unread message

Emrah Sezer

unread,
May 4, 2020, 5:53:30 PM5/4/20
to python-weka-wrapper
Hello

I couldn't install javabridge and Weka while using the colab platform.
Is there anyone who is experienced in this issue?
I faced this message;

'' /usr/local/lib/python3.6/dist-packages/IPython/utils/traitlets.py:5: UserWarning: IPython.utils.traitlets has moved to a top-level traitlets package. ''

Thanks in advance


Peter Reutemann

unread,
May 4, 2020, 6:09:35 PM5/4/20
to python-weka-wrapper
> I couldn't install javabridge and Weka while using the colab platform.
> Is there anyone who is experienced in this issue?

Other users have experienced problems with running pww3 from
notebooks. In the past (not sure whether this got ever resolved), the
javabridge library, which is used by pww3 to communicate with the JVM,
did not allow restarting the JVM, e.g., when restarting a cell in a
notebook. The whole notebook process had to be restarted.

I recommend using pww3 outside of notebooks, in a local virtual Python
environment.

Disclaimer: I haven't used Colab myself.

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/

Hashsham Maneri

unread,
Aug 7, 2020, 4:40:51 AM8/7/20
to python-weka-wrapper
This is a bit late but I hope it helps.

I got Weka to work on colab using the following commands:

!sudo apt-get update
!apt-get install openjdk-8-jdk-headless -qq > /dev/null
import os
os.environ["JAVA_HOME"] = "/usr/lib/jvm/java-8-openjdk-amd64"
!update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
!java -version


!apt-get install build-essential python3-dev
!apt-get install python3-pil python3-pygraphviz
!pip3 install javabridge --no-cache-dir
!pip3 install python-weka-wrapper3 --no-cache-dir

Basically, installing Java from OpenJDK and setting it as default Java helps. However, I have not been able to get AutoWeka working.

raul.para...@gmail.com

unread,
Apr 22, 2021, 5:17:11 AM4/22/21
to python-weka-wrapper
I would like to use the packages timeseriesForecasting and Alternating Model Tree in Colab. The above code works, however, I don't know how to import those packages from the local Weka installation (3.9.5.). The jvm started with package support "jvm.start(packages=True)"

Here the error:

Failed to instantiate forecaster 'weka.classifiers.timeseries.WekaForecaster' - is package 'timeseriesForecasting' installed and jvm started with package support?

I guess if Iyou've made AutoWeka work, it could be the same operation to other packages.

El dia divendres, 7 d’agost de 2020 a les 10:40:51 UTC+2, hashsha...@gmail.com va escriure:

Peter Reutemann

unread,
Apr 22, 2021, 6:54:23 PM4/22/21
to python-weka-wrapper
> I would like to use the packages timeseriesForecasting and Alternating Model Tree in Colab. The above code works, however, I don't know how to import those packages from the local Weka installation (3.9.5.). The jvm started with package support "jvm.start(packages=True)"
>
> Here the error:
>
> Failed to instantiate forecaster 'weka.classifiers.timeseries.WekaForecaster' - is package 'timeseriesForecasting' installed and jvm started with package support?
>
> I guess if Iyou've made AutoWeka work, it could be the same operation to other packages.

Using "packages=True" only means that pww3 makes use of any Weka
packages that you have installed. If "False" it ignores them
completely when starting.

You will still have to install any package that you want to use in
Colab, of course:
http://fracpete.github.io/python-weka-wrapper3/examples.html#packages
http://fracpete.github.io/python-weka-wrapper3/weka.core.html#module-weka.core.packages

Disclaimer: I don't use Colab.

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

raul.para...@gmail.com

unread,
Apr 23, 2021, 2:47:45 AM4/23/21
to python-weka-wrapper
I've tried to install alternatingModelTree using the following command 

packages.install_package("alternatingModelTrees")

but I get this debug log:

alternatingModelTrees http://prdownloads.sourceforge.net/weka/alternatingModelTrees1.0.1.zip?download timeseriesForecasting http://prdownloads.sourceforge.net/weka/timeseriesForecasting1.1.27.zip?download Failed to instantiate weka.classifiers.trees.AlternatingModelTree: Can't find a permissible class called: weka.classifiers.trees.AlternatingModelTree Class 'weka.classifiers.trees.AlternatingModelTree' is available from package: alternatingModelTrees

and this error:

--> cls = Classifier(classname="weka.classifiers.trees.AlternatingModelTree")
-> assert o is not None 
env = get_env() 
 if isinstance(o, basestring): 
AssertionError: 
El dia divendres, 23 d’abril de 2021 a les 0:54:23 UTC+2, Peter Reutemann va escriure:

Peter Reutemann

unread,
Apr 23, 2021, 4:05:53 AM4/23/21
to python-weka-wrapper
Did you restart your environment after you installed the Weka
packages? Packages that you install within a session are not available
immediately, the Java Virtual Machine needs to get restarted for that.

Cheers, Peter
> --
> 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 view this discussion on the web visit https://groups.google.com/d/msgid/python-weka-wrapper/8e87d758-6110-4b00-ac62-7e52a5d85192n%40googlegroups.com.

raul.para...@gmail.com

unread,
Apr 23, 2021, 5:19:23 AM4/23/21
to python-weka-wrapper
The packages were installed before JVM started. If i try:
jvm.start()
packages.install_package("timeseriesForecasting")
packages.install_package("alternatingModelTrees")
jvm.stop()
jvm.start(packages=True, system_info=True)

I get the following error:

RuntimeError: Failed to start Java VM


El dia divendres, 23 d’abril de 2021 a les 10:05:53 UTC+2, Peter Reutemann va escriure:

Peter Reutemann

unread,
Apr 23, 2021, 5:37:17 AM4/23/21
to python-we...@googlegroups.com
The jvm cannot be restarted once stopped, unfortunately. A limitation of the javabridge library.

You have to restart your environment.
Using Jupyter notebooks, this would be the kernel.

Cheers, Peter
>> >> +64 (7) 577-5304 <+64%207-577%205304>
>> >> 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 view this discussion on the web visit
>>
>https://groups.google.com/d/msgid/python-weka-wrapper/8e87d758-6110-4b00-ac62-7e52a5d85192n%40googlegroups.com
>> .
>>
>>
>>
>> --
>> Peter Reutemann
>> Dept. of Computer Science
>> University of Waikato, NZ
>> +64 (7) 577-5304 <+64%207-577%205304>

raul.para...@gmail.com

unread,
Apr 23, 2021, 6:41:27 AM4/23/21
to python-weka-wrapper
Great! It works!

El dia divendres, 23 d’abril de 2021 a les 11:37:17 UTC+2, frac...@gmail.com va escriure:
Reply all
Reply to author
Forward
0 new messages