I want to use Weka in my python code, so I install java-wrapper python(2.7.16 ) according to https://fracpete.github.io/python-weka-wrapper/install.html and my java version is: java version "1.8.0_201" Java(TM) SE Runtime Environment (build 1.8.0_201-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
Also, I added the JDK path to user variable PATH according to https://troubleshooter.xyz/wiki/fix-java-virtual-machine-jvm-not-found-error/
but it raise error:
>>>import os
>>>import traceback
>>>import weka.core.jvm as jvm
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\weka\core\jvm.py", line 17, in
<module>
import javabridge
File "C:\Python27\lib\site-packages\javabridge\__init__.py", line 38, in
<module>
from .jutil import start_vm, kill_vm, vm, activate_awt, deactivate_awt
File "C:\Python27\lib\site-packages\javabridge\jutil.py", line 151, in
<module>
os.pathsep + os.path.join(find_javahome(), "bin")
File "C:\Python27\lib\site-packages\javabridge\jutil.py", line 139, in
_find_jvm
raise JVMNotFoundError()
javabridge.jutil.JVMNotFoundError: Can't find the Java Virtual Machine
I'm not a Windows user and setting up Python always seems to be riddled with issues... But I finally had some time setting up a Windows 10 instance... Here is what I did:
JAVA_HOME
variable definedwhere java
C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe
C:\ProgramData\Oracle\Java\javapath\java.exe
java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
VC++ compiler for Python 2.7 (for compiling javabridge)
Anaconda for Python 2.7 (4.3.0.1)
https://repo.continuum.io/archive/Anaconda2-4.3.0.1-Windows-x86_64.exe
value of PATH after installing anaconda:
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Anaconda2;C:\Anaconda2\Scripts;C:\Anaconda2\Library\bin;C:\Users\fracpete\AppData\Local\Microsoft\WindowsApps;
conda create -n py27-pww numpy
activate py27-pww
pip install python-weka-wrapper
python
import weka.core.jvm as jvm
jvm.start()
from weka.classifiers import Classifeir
cls = Classifier(classname="weka.classifiers.trees.J48")
print(cls)
jvm.stop()