Skip to content

What is JAVA_HOME? #49

@thuychang404

Description

@thuychang404

Hi, I'm currently running your code in my VSCode, and I came across this error:


Traceback (most recent call last):
  File "path\name\nlp.py", line 8, in <module>
    model = py_vncorenlp.VnCoreNLP(save_dir='/models')
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\py_vncorenlp\vncorenlp.py", line 53, in __init__
    from jnius import autoclass
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\jnius\__init__.py", line 18, in <module>        
    java = get_java_setup(sys.platform)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\jnius\env.py", line 60, in get_java_setup
    JAVA_HOME = get_jdk_home(platform)
                ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\jnius\env.py", line 335, in get_jdk_home
    raise Exception('Unable to find JAVA_HOME')
Exception: Unable to find JAVA_HOME

I really don't get it. Please help.
P/S: The code I'm using:

import py_vncorenlp
import os
import shutil

# Load VnCoreNLP model
model = py_vncorenlp.VnCoreNLP(save_dir='/models')

# Annotate a raw text
text = "Ông Nguyễn Khắc Chúc đang làm việc tại Đại học Quốc gia Hà Nội. Bà Lan, vợ ông Chúc, cũng làm việc tại đây."
annotated_text = model.annotate(text)
print(annotated_text)

# Annotate a file
input_file_path = "/input.txt"
output_file_path = "/output.txt"
model.annotate_file(input_file=input_file_path, output_file=output_file_path)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions