how to use Okt of konlpy.tag in the jupyter notebook

hi,

I’m trying to do text mining using jupyter notebook.
but when i use function OKT in library konlpy.tag, error is happening.

could you help me?

this is script what i try.

------------------------------------------
from konlpy.tag import Okt
text ='전처리가 다 완료된 테스트를 형태소 분석기를 활용해서 구분해보겠습니다.'

okt = Okt()

okt.pos(text)
-------------------------------------------

and this is error. i wonder this is because of java_home setting

-------------------------------------------
JVMNotFoundException                      Traceback (most recent call last)
Cell In[1], line 4
      1 from konlpy.tag import Okt
      2 text ='전처리가 다 완료된 테스트를 형태소 분석기를 활용해서 구분해보겠습니다.'
----> 4 okt = Okt()
      6 okt.pos(text)

File ~/envs/default/lib/python3.13/site-packages/konlpy/tag/_okt.py:51, in Okt.__init__(self, jvmpath, max_heap_size)
     49 def __init__(self, jvmpath=None, max_heap_size=1024):
     50     if not jpype.isJVMStarted():
---> 51         jvm.init_jvm(jvmpath, max_heap_size)
     53     oktJavaPackage = jpype.JPackage('kr.lucypark.okt')
     54     OktInterfaceJavaClass = oktJavaPackage.OktInterface

File ~/envs/default/lib/python3.13/site-packages/konlpy/jvm.py:55, in init_jvm(jvmpath, max_heap_size)
     52 args = [javadir, os.sep]
     53 classpath = [f.format(*args) for f in folder_suffix]
---> 55 jvmpath = jvmpath or jpype.getDefaultJVMPath()
     57 # NOTE: Temporary patch for Issue #76. Erase when possible.
     58 if sys.platform == 'darwin'\
     59         and jvmpath.find('1.8.0') > 0\
     60         and jvmpath.endswith('libjvm.dylib'):

File ~/envs/default/lib/python3.13/site-packages/jpype/_jvmfinder.py:70, in getDefaultJVMPath()
     68 else:
     69     finder = LinuxJVMFinder()
---> 70 return finder.get_jvm_path()

File ~/envs/default/lib/python3.13/site-packages/jpype/_jvmfinder.py:204, in JVMFinder.get_jvm_path(self)
    202 if jvm_notsupport_ext is not None:
    203     raise jvm_notsupport_ext
--> 204 raise JVMNotFoundException("No JVM shared library file ({0}) "
    205                            "found. Try setting up the JAVA_HOME "
    206                            "environment variable properly."
    207                            .format(self._libfile))

JVMNotFoundException: No JVM shared library file (libjvm.so) found. Try setting up the JAVA_HOME environment variable properly.
-------------------------------------------

thanks!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.