Reputation: 23
import weka.core.jvm as jvm
jvm.start()
data_dir = "C:/Data/Python/Weka/Data/"
from weka.core.converters import Loader
loader = Loader(classname="weka.core.converters.ArffLoader")
data = loader.load_file(data_dir + "logistic.arff")
data.class_is_last()
print(data)
I'm executing the above example code of weka python wrapper from their doc. So I'm sure that there's no problem in the code. All modules are installed. But the code is not working when it is run as script (by pressing F5 in IDLE). It is throwing the following error:
Traceback (most recent call last):
File "C:\Data\Python\Weka\weka.py", line 1, in <module>
import weka.core.jvm as jvm
File "C:\Data\Python\Weka\weka.py", line 1, in <module>
import weka.core.jvm as jvm
ImportError: No module named core.jvm
But the code works when I copy and paste it line by line to the IDLE command prompt. No idea why. Where did I go wrong?
Upvotes: 2
Views: 1828
Reputation: 3386
Try changing the name of your file to something that's not the name of any of the module you're importing. For example change weka.py
to myscript.py
Upvotes: 5