์ธ๊ณต์ง€๋Šฅ ๐ŸŒŒ/์ž์—ฐ์–ด ์ฒ˜๋ฆฌ

[์ž์—ฐ์–ด ์ฒ˜๋ฆฌ] konlpy ์„ค์น˜ ์˜ค๋ฅ˜, okt()์—๋Ÿฌ-already loaded in another classloader, SystemErro

23.8 2021. 7. 11. 05:11
๋ฐ˜์‘ํ˜•



์ž์—ฐ์–ด ์ฒ˜๋ฆฌ ์‹ค์Šต์„ ํ•˜๊ธฐ ์œ„ํ•ด konlpy๋ฅผ ์„ค์น˜ํ•˜๋˜ ์ค‘ ์ˆ˜ ์ฐจ๋ก€์˜ ์˜ค๋ฅ˜๋ฅผ ๋งž์ดํ–ˆ์Šต๋‹ˆ๋‹ค...๐Ÿ˜ญ๐Ÿ˜ญ

์ €๋Š” ํ™˜๊ฒฝ๋ณ€์ˆ˜๋ถ€ํ„ฐ pip, konlpy ํ˜ธ์ถœ ๋“ฑ ๋ชจ๋“  ๋ถ€๋ถ„์—์„œ ์—๋Ÿฌ๋ฅผ ๊ฒผ์—ˆ๋Š”๋ฐ์š”,,,,ใ…Ž ๊ด€๋ จ ์ง€์‹์€ ๊ฑฐ์˜ ์—†์ง€๋งŒ ์ €์™€ ๊ฐ™์€ ์˜ค๋ฅ˜๋ฅผ ๊ฒช์œผ์‹ค ๋ถ„๋“ค์„ ์œ„ํ•ด ์ œ๊ฐ€ ์˜ค๋ฅ˜๋ฅผ ํ•ด๊ฒฐํ•œ ๋ฐฉ๋ฒ•์„ ์ ์–ด๋†จ์Šต๋‹ˆ๋‹ค.

(ํ˜น์‹œ ์ง€๋‚˜๊ฐ€์‹œ๋Š” ๊ธธ ์ถ”๊ฐ€์„ค๋ช…์ด ์žˆ๋‹ค๋ฉด ๊ฐ์‚ฌํžˆ ๋ฐ›๊ฒ ์Šต๋‹ˆ๋‹ค!)



๊ทธ๋Ÿผ ํ˜•ํƒœ์†Œ ๋ถ„์„๊ธฐ ์ค‘ ํ•˜๋‚˜์ธ konlpy๋ฅผ ์„ค์น˜ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค!! ์„ค์น˜๋ฅผ ์œ„ํ•œ ๊ณผ์ •์€ ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

1. JAVA ์„ค์น˜
2. JAVA_HOME ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์„ค์ •
3. JPype ๋‹ค์šด๋กœ๋“œ ๋ฐ ์„ค์น˜
4. konlpy ์„ค์น˜


1. JAVA ์„ค์น˜

์šฐ์„  JAVA๋ฅผ ๋จผ์ € ์„ค์น˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค! JAVA๋Š” ์•„๋ž˜์˜ ์‚ฌ์ดํŠธ์—์„œ ์„ค์น˜๊ฐ€ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค
https://www.oracle.com/java/technologies/javase-downloads.html
์‚ฌ์ดํŠธ์— ๋“ค์–ด๊ฐ€ JDK Download >> ์ž์‹ ์˜ ์šด์˜์ฒด์ œ์™€ ๋งž๋Š” ๊ฒƒ ๋‹ค๋ฃฌ๋กœ๋“œ >> ๊ธฐ๋ณธ ์„ค์ •์œผ๋กœ ์ญ‰ ๋‹ค์šด๋กœ๋“œ


2. JAVA_HOME ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์„ค์ •

์ด์ œ C ๋“œ๋ผ์ด๋ธŒ์˜ Program Files >> Java >> jek-์ž์‹ ์˜ version >> bin์˜ ๊ฒฝ๋กœ๋ฅผ path๋กœ ๋“ฑ๋ก์„ ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค!
C:\Program Files\Java\jdk-14\bin ๋ณธ์ธ์˜ bin์— ํ•ด๋‹นํ•˜๋Š” ๊ฒฝ๋กœ๋ฅผ ๋ณต์‚ฌํ•œ๋‹ค์Œ
(ํŒŒ์ผ ํƒ์ƒ‰๊ธฐ์—์„œ ์•„๋ž˜ ๋ถ€๋ถ„์„ ํด๋ฆญํ•˜๋ฉด ์ฃผ์†Œ ๋ณต์‚ฌ ๊ฐ€๋Šฅ)


ํŒŒ์ผ ํƒ์ƒ‰๊ธฐ์˜ ๋‚ด PC์—์„œ ์šฐํด๋ฆญ >> ์†์„ฑ
๊ทธ๋Ÿฌ๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ์‹œ์Šคํ…œ ์ฐฝ์ด ๋œน๋‹ˆ๋‹ค ์—ฌ๊ธฐ์„œ ๊ณ ๊ธ‰ ์‹œ์Šคํ…œ ์„ค์ •



์ด๋ ‡๊ฒŒ ์ƒˆ ์‹œ์Šคํ…œ ๋ณ€์ˆ˜์— ๋ณ€์ˆ˜ ์ด๋ฆ„์€ JAVA_HOME,
๋ณ€์ˆ˜ ๊ฐ’์—๋Š” ์•„๊นŒ ๋ณต์‚ฌํ•œ ๊ฒฝ๋กœ๋ฅผ ๋ถ™์—ฌ ๋„ฃ๊ธฐ ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ํ™•์ธ ๋ฒ„ํŠผ ํด๋ฆญ!


๊ทธ๋Ÿฌ๋ฉด ์‹œ์Šคํ…œ ๋ณ€์ˆ˜์— JAVA_HOME์ด ์ƒ๊ธด ๊ฒƒ์„ ํ™•์ธ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค


์ด์ œ Path๋ฅผ ๋”๋ธ” ํด๋ฆญ or ํŽธ์ง‘ ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ์ค๋‹ˆ๋‹ค

.์ƒˆ๋กœ ๋งŒ๋“ค๊ธฐ ํ›„ ์•ž๊ณผ ๋™์ผํ•œ ๊ฒฝ๋กœ๋ฅผ ๋ณต์‚ฌํ•ด์ฃผ๊ณ  ๋–  ์žˆ๋Š” ์ฐฝ๋“ค์— ๊ณ„์† ํ™•์ธ ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค!

์ž˜ ์ ์šฉ๋๋‚˜ ํ™•์ธํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด cmd์—์„œ "set JAVA_HOME"๋ช…๋ น์–ด ์ž…๋ ฅ ํ›„ ์•„๊นŒ ์ž…๋ ฅํ•œ ๊ฒฝ๋กœ๊ฐ€ ๋‚˜์˜ค๋Š”์ง€ ํ™•์ธํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค


3. JPype ๋‹ค์šด๋กœ๋“œ ๋ฐ ์„ค์น˜

https://www.lfd.uci.edu/~gohlke/pythonlibs/#jpype

Python Extension Packages for Windows - Christoph Gohlke

by Christoph Gohlke, Laboratory for Fluorescence Dynamics, University of California, Irvine. Updated on 7 July 2021 at 21:21 UTC. This page provides 32- and 64-bit Windows binaries of many scientific open-source extension packages for the official CPython

www.lfd.uci.edu

ํ•ด๋‹น ์ฃผ์†Œ์—์„œ ๋ณธ์ธ์˜ ์‚ฌ์–‘๊ณผ ๋งž๋Š” ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ


cmd์—์„œ ์œ„์™€ ๊ฐ™์ด ๋ฐฉ๊ธˆ ๋‹ค์šด๋กœ๋“œํ•œ ํŒŒ์ผ๋ช…๊ณผ ํ•จ๊ป˜ "pip install ํŒŒ์ผ๋ช…. whl"์„ ํ•˜๋ฉด ๋˜๋Š”๋ฐ์š”
์ €๋Š” ์ด๋ฏธ ์„ค์น˜๊ฐ€ ๋˜์–ด์žˆ์–ด์„œ ์œ„์™€ ๊ฐ™์ด ๋œน๋‹ˆ๋‹ค!

์ด๋•Œ ์—ฌ๊ธฐ์„œ pip๊ฐ€ ๋ช…๋ น์–ด๊ฐ€ ์•„๋‹ˆ๋ผ๊ณ  ๋œจ์‹œ๋Š” ๋ถ„๋“ค์€ ํŒŒ์ด์ฌ์„ ๋‹ค์‹œ ์„ค์น˜ํ•˜์‹œ๋Š” ๊ฒƒ์„ ์ถ”์ฒœ๋“œ๋ฆฝ๋‹ˆ๋‹น..
pip๊ด€๋ จํ•ด์„œ ๊ตฌ๊ธ€๋ง์„ ์—ฌ๋Ÿฌ๋ฒˆ ํ•ด๋ดค๋Š”๋ฐ ๊ฒฐ๊ตญ ๋‹ค ์‹คํŒจํ•˜๊ณ  ํŒŒ์ด์ฌ ๋‹ค์‹œ ์„ค์น˜ํ•  ๋•Œ path๋“ฑ๋ก ์ฒดํฌํ•˜๊ณ  ๋‹ค์šด๋กœ๋“œํ•˜๋‹ˆ ๋ฐ”๋กœ ํ•ด๊ฒฐ๋์Šต๋‹ˆ๋‹ค
path ๊ด€๋ จ ๋ฌธ์ œ์ธ ๊ฒƒ ๊ฐ™์€๋ฐ ๋“ฑ๋กํ•  ์ˆ˜ ๋„ ์žˆ์ง€๋งŒ ์žฌ ์„ค์น˜๊ฐ€ ์‰ฝ๊ณ  ๋น ๋ฅธ ๊ธธ์ด๋”๋ผ๊ณ ์š”,,,ใ… ใ… 


4. install konlpy


์—ฌ๊ธฐ๊นŒ์ง€ ์„ฑ๊ณตํ–ˆ๋‹ค๋ฉด ์ž˜ ์„ค์น˜๊ฐ€ ๋๋‚˜ ํ™•์ธ์„ ํ•ด ๋ด์•ผ๊ฒ ์ฃ ??

์ €๋Š” ์ฃผํ”ผํ„ฐ์—์„œ ์•„๋ž˜์˜ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•ด์คฌ์Šต๋‹ˆ๋‹ค

pip install konlpy
import konlpy from konlpy.tag import Okt okt = Okt()

์‹คํ–‰ํ•œ ๋’ค ๋ณ„ ์ด์ƒ ์—†๊ธธ๋ž˜ ์•„ ๋“œ๋””์–ด ๋˜๋Š” ๊ฑด๊ฐ€๋ผ๊ณ  ์ƒ๊ฐํ–ˆ๋Š”๋ฐ ๋ช‡ ์ดˆ ๋’ค์— ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.

SystemError: java.lang.UnsatisfiedLinkError: Native Library C:\Programming\Anaconda3\Lib\site-packages\_jpype.cp38-win_amd64.pyd already loaded in another classloader

๋ ์šฉ.... ์ €๋Š” import๊นŒ์ง€๋Š” ๋ฌธ์ œ๊ฐ€ ์—†์–ด ๋ณด์˜€๋Š”๋ฐ okt=Okt() ์ฝ”๋“œ์—์„œ ์—๋Ÿฌ๊ฐ€ ๋‚ฌ์Šต๋‹ˆ๋‹ค.

์ €๊ฒŒ ๋ฌด์Šจ ์†Œ๋ฆฌ์ง€ ๊ตฌ๊ธ€๋ง ํ•˜๋ฉด์„œ ์—ฌ๋Ÿฌ ๊ธ€์„ ์ฝ๋‹ค๊ฐ€ ๋ถˆํ˜„๋“ฏ ๋ฌด์—‡์ด ๋จธ๋ฆฟ์†์„ ์Šค์น˜๊ณ  ์ง€๋‚˜๊ฐ”์Šต๋‹ˆ๋‹ค.
์ €๋Š” ์˜ˆ์ „์— JAVA ํ™˜๊ฒฝ๋ณ€์ˆ˜๋ฅผ ๋“ฑ๋กํ•œ ๊ธฐ์–ต์ด ์žˆ์–ด์„œ 1,2๋‹จ๊ณ„๋ฅผ ์•ˆ๊ฑฐ์น˜๊ณ  ๋ฐ”๋กœ 3๋‹จ๊ณ„๋กœ ๊ฐ”์—ˆ๋Š”๋ฐ
3๋‹จ๊ณ„์—์„œ pip ๋ช…๋ น์–ด๊ฐ€ ์•ˆ ๋˜๋Š” ๊ฒŒ ํ™˜๊ฒฝ๋ณ€์ˆ˜ ๋ฌธ์ œ ๋•Œ๋ฌธ์ธ์ง€ ์•Œ๊ณ  ํ™˜๊ฒฝ๋ณ€์ˆ˜๋ฅผ ๋‹ค์‹œ ๋งŒ๋“ค์–ด์คฌ์Šต๋‹ˆ๋‹ค.
๊ทธ๋Ÿฐ๋ฐ ๋‚˜์ค‘์— ํ™•์ธํ•ด ๋ณด๋‹ˆ ์˜ˆ์ „์— ํ™˜๊ฒฝ๋ณ€์ˆ˜ ๋“ฑ๋กํ•ด ๋†“์€ ๊ฒƒ์ด ์žˆ์–ด์„œ ํ™˜๊ฒฝ๋ณ€์ˆ˜๊ฐ€ ์ค‘๋ณต์œผ๋กœ ๋“ฑ๋ก์ด ๋ผ๋ฒ„๋ ธ์Šต๋‹ˆ๋‹ค.
๊ทธ๋ž˜์„œ ์ด๋Ÿด ๋•Œ๋Š” ํ™˜๊ฒฝ๋ณ€์ˆ˜๊ฐ€ ์ค‘๋ณต๋œ ์ง€ ํ™•์ธ์„ ํ•ด๋ณด์‹œ๊ธธ ์ถ”์ฒœ๋“œ๋ฆฝ๋‹ˆ๋‹ค.


ํŒŒ์ผ ํƒ์ƒ‰๊ธฐ์˜ ๋‚ด PC์—์„œ ์šฐํด๋ฆญ >> ์†์„ฑ
๊ทธ๋Ÿฌ๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ์‹œ์Šคํ…œ ์ฐฝ์ด ๋œน๋‹ˆ๋‹ค ์—ฌ๊ธฐ์„œ ๊ณ ๊ธ‰ ์‹œ์Šคํ…œ ์„ค์ •


์œ„์—์„œ ๋ณด์ด๋“ฏ์ด java ๋™์ผํ•œ ํ™˜๊ฒฝ๋ณ€์ˆ˜๊ฐ€ ์ค‘๋ณต์ด ๋˜์–ด์žˆ์–ด์„œ ํ•˜๋‚˜๋ฅผ ์‚ญ์ œํ•ด์คฌ๋”๋‹ˆ ์œ„์˜ ์—๋Ÿฌ๋Š” ํ•ด๊ฒฐ์ด ๋์Šต๋‹ˆ๋‹ค!!!!
์ด์ œ ๋‹ค์‹œ ์‹คํ–‰ํ•ด์„œ ์ž˜ ๋™์ž‘ํ•  ์ค„ ์•Œ์•˜๋Š”๋ฐ.......



SystemError: java.nio.file.InvalidPathException: Illegal char <*> at index 55: C:\Programming\Anaconda3\Lib\site-packages\konlpy\java\*

์„ธ์ƒ์€ ๊ทธ๋ ‡๊ฒŒ ํ˜ธ๋ฝํ˜ธ๋ฝํ•˜์ง€ ์•Š๋„ค์š”..ใ…Ž ์ƒˆ๋กญ๊ฒŒ ๋ฌธ์ œ๊ฐ€ ์ƒ๊ฒผ์Šต๋‹ˆ๋‹ค^^,,,, ์ด๊ฒƒ๋„ ๊ตฌ๊ธ€๋ง ํ•ด๋ณธ ๊ฒฐ๊ณผ ์•„๋ž˜์˜ ๊ธ€์—์„œ ๋‹ต์„ ์ฐพ์•˜์Šต๋‹ˆ๋‹ค.
https://github.com/konlpy/konlpy/issues/349

InvalidPathException ยท Issue #349 ยท konlpy/konlpy

PS C:\WINDOWS\system32> python Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or...

github.com



C:\Programming\Anaconda3\Lib\site-packages\konlpy
์ €๋Š” ์œ„์˜ ๊ฒฝ๋กœ์˜€๋Š”๋ฐ์š”, ๊ฐ์ž ๋ณธ์ธ์˜ ์ปดํ“จํ„ฐ์—์„œ konlpy๊ฐ€ ์„ค์น˜๋ผ ์žˆ๋Š” ๊ฒฝ๋กœ๋กœ ๊ฐ€์„œ jvm.py ํŒŒ์ผ์— ์žˆ๋Š” * ๋ฅผ ์ง€์›Œ์•ผ ํ•ฉ๋‹ˆ๋‹ค.


jvm.pyํŒŒ์ผ์„ ์—ด๋ฉด ์œ„์˜ ์ฝ”๋“œ๋“ค์ด ๋ณด์ด๋Š”๋ฐ์š” ๊ทธ์ค‘ ์‚ฌ์ง„์˜ ๋…ธ๋ž€์ƒ‰ ํ˜•๊ด‘ํŽœ ์น ํ•ด์ ธ ์žˆ๋Š” ๋ถ€๋ถ„์„ ์ง€์šฐ๊ณ  ์ €์žฅํ•ด๋ณผ๊ฒŒ์š”

์ €์žฅ ํ›„ ๋‹ค์‹œ ์‹คํ–‰ํ•˜๋‹ˆ okt=Okt() ์ฝ”๋“œ๊ฐ€ ์—๋Ÿฌ ์—†์ด ์ž˜ ๋™์ž‘ํ•˜์˜€์Šต๋‹ˆ๋‹คใ… ใ… ใ… 



์ €๋Š” ์„ค์น˜๊ณผ์ • ๋™์•ˆ ์ •๋ง ํ˜ผ์ž์„œ ์‚ฝ์งˆ์„ ๋งŽ์ด ํ–ˆ๊ธฐ์— ์ € ๊ฐ™์€ ์˜ค๋ฅ˜๋ฅผ ๋งŒ๋‚˜์‹œ๋Š” ๋ถ„๋“ค๊ป˜ ๋„์›€์ด ์กฐ๊ธˆ์ด๋‚˜๋งˆ ๋๊ธธ ๋ฐ”๋ผ๊ฒ ์Šต๋‹ˆ๋‹คใ… !


728x90
๋ฐ˜์‘ํ˜•