Error importing package in Colab

71 views
Skip to first unread message

raul.para...@gmail.com

unread,
Apr 22, 2021, 5:56:52 AM4/22/21
to python-weka-wrapper
I could install javabridge, python-weka-wrapper, Weka and packages into Colab. However, I get the following error:

cannot import name 'NumericPrediction' from 'weka.classifiers' (/usr/local/lib/python3.7/dist-packages/weka/classifiers.py)

When using the following header:

import os
import sys
sys.path
sys.path.append("/usr/lib/jvm/java-11-openjdk-amd64/bin/")
os.environ["JAVA_HOME"] = "/usr/lib/jvm/java-11-openjdk-amd64/"
!apt-get install build-essential python3-dev
!apt-get install python3-pil python3-pygraphviz
!apt install openjdk-11-jdk
!apt-get install -y weka libsvm-java
!pip3 install weka
!pip3 install javabridge --no-cache-dir
!pip3 install python-weka-wrapper3 --no-cache-dir
import javabridge
import weka.core.jvm as jvm
from weka.core.converters import Loader
from weka.core.dataset import Instances
import traceback
import weka.core.packages as packages
packages.install_package("timeseriesForecasting")
from weka.timeseries import WekaForecaster
from weka.classifiers import Classifier

Did you face the same issue?

Thanks

Peter Reutemann

unread,
Apr 22, 2021, 7:00:16 PM4/22/21
to python-weka-wrapper
> I could install javabridge, python-weka-wrapper, Weka and packages into Colab. However, I get the following error:
>
> cannot import name 'NumericPrediction' from 'weka.classifiers' (/usr/local/lib/python3.7/dist-packages/weka/classifiers.py)
>
> When using the following header:
>
> import os
> import sys
> sys.path
> sys.path.append("/usr/lib/jvm/java-11-openjdk-amd64/bin/")
> os.environ["JAVA_HOME"] = "/usr/lib/jvm/java-11-openjdk-amd64/"
> !apt-get install build-essential python3-dev
> !apt-get install python3-pil python3-pygraphviz
> !apt install openjdk-11-jdk
> !apt-get install -y weka libsvm-java

Why are you installing Weka? pww3 comes with Weka automatically.
On my Linux Mint, this is a really old version of Weka (3.6.14) when
using "apt-cache show weka".

> !pip3 install weka

The "Weka" Python library (https://pypi.org/project/weka/) has the
same module structure as pww3. This module name clash will be the
source of your problem.

You can either have a system with the Weka library or pww3, but not
together at the same time. You need two separate environments for
that.

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/
Reply all
Reply to author
Forward
0 new messages