http://konlpy.org/ko/latest/
해당 패키지는 아직 ppc64le용 Anaconda 채널에 포함되어 있지 않습니다. 따라서 pypi 사이트(https://pypi.org/)에서 제공하고 있는 whl 파일을 이용하여 설치해야 하는데, 설치 자체는 pip 명령어로 간단하게 수행할 수 있습니다.
다만, 이 패키지를 설치할때, JPype1 패키지도 필수로 필요한데, JPype1 패키지는 ppc64le용 whl도 제공되지 않고, 기본 Anaconda 채널에 포함되어 있지 않기 때문에 직접 소스코드를 빌드하고 설치하는 작업을 선행 후, KoNLPy 패키지를 설치해보겠습니다. (기타 요구 패키지는 Anaconda3 에서 conda install 명령어로 설치 가능하며, 구성 시 자동 설치됩니다.)
Konlpy whl 파일 다운로드 링크 https://files.pythonhosted.org/packages/85/0e/f385566fec837c0b83f216b2da65db9997b35dd675e107752005b7d392b1/konlpy-0.5.2-py2.py3-none-any.whl
JPype1 소스코드 다운로드 링크
https://files.pythonhosted.org/packages/d7/62/0f312d578e0165e9b5e8fcae0291f7ee83783b3805f59071006b21229d55/JPype1-0.7.1.tar.gz
아래 환경에서는 Python 3.6 사용자 기준으로 패키지를 빌드합니다.
먼저 Jpype1 패키지의 소스코드를 다운로드 받아서 서버에 올려둡니다.
[root@p625-kvm1 cecuser]# tar -xvf JPype1-0.7.1.tar.gz
[root@p625-kvm1 cecuser]# cd JPype1-0.7.1/
현재 사용하는 Python은 Anaconda3에 포함된 Python 3.6.9 버전이고, GCC 7.3.0 으로 빌드되어 있습니다. 따라서, JPype1 을 빌드할때도 gcc 7.3.0 버전 이상을 사용해주어야 합니다.
[root@p625-kvm1 JPype1-0.7.1]# /opt/anaconda3/bin/python
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:18:58)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
제가 작업한 서버의 기본 환경은 gcc 버전이 4.8.5 입니다.
[root@p625-kvm1 cecuser]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
gcc 7.3.x 버전을 설치하기 위해서, 아래의 devtoolset을 설치합니다. 이후, 기본 PATH를 잠시 변경하여 gcc 7.3.x 버전이 먼저 사용되도록 합니다.
[root@p625-kvm1 JPype1-0.7.1]# yum install devtoolset-7-gcc-c++.ppc64le
[root@p625-kvm1 JPype1-0.7.1]# export PATH=/opt/rh/devtoolset-7/root/usr/bin:$PATH
[root@p625-kvm1 cecuser]# gcc --version
gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
이제 Anaconda에 포함된 Python3으로 JPype1을 빌드합니다.
[root@p625-kvm1 JPype1-0.7.1]# /opt/anaconda3/bin/python setup.py build/opt/anaconda3/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'use_scm_version'
warnings.warn(msg)
running build
g++ -pthread -shared -B /opt/anaconda3/compiler_compat -L/opt/anaconda3/lib -Wl,-rpath=/opt/anaconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-ppc64le-3.6/build/src/jp_thunk.o build/temp.linux-ppc64le-3.6/native/common/jp_array.o build/temp.linux-ppc64le-3.6/native/common/jp_arrayclass.o build/temp.linux-ppc64le-3.6/native/common/jp_baseclasses.o build/temp.linux-ppc64le-3.6/native/common/jp_booleantype.o build/temp.linux-ppc64le-3.6/native/common/jp_boxedclasses.o build/temp.linux-ppc64le-3.6/native/common/jp_bytetype.o build/temp.linux-ppc64le-3.6/native/common/jp_chartype.o build/temp.linux-ppc64le-3.6/native/common/jp_class.o build/temp.linux-ppc64le-3.6/native/common/jp_classloader.o build/temp.linux-ppc64le-3.6/native/common/jp_doubletype.o build/temp.linux-ppc64le-3.6/native/common/jp_encoding.o build/temp.linux-ppc64le-3.6/native/common/jp_env.o build/temp.linux-ppc64le-3.6/native/common/jp_exception.o build/temp.linux-ppc64le-3.6/native/common/jp_field.o build/temp.linux-ppc64le-3.6/native/common/jp_floattype.o build/temp.linux-ppc64le-3.6/native/common/jp_inttype.o build/temp.linux-ppc64le-3.6/native/common/jp_jniutil.o build/temp.linux-ppc64le-3.6/native/common/jp_longtype.o build/temp.linux-ppc64le-3.6/native/common/jp_method.o build/temp.linux-ppc64le-3.6/native/common/jp_methodoverload.o build/temp.linux-ppc64le-3.6/native/common/jp_monitor.o build/temp.linux-ppc64le-3.6/native/common/jp_primitivetype.o build/temp.linux-ppc64le-3.6/native/common/jp_proxy.o build/temp.linux-ppc64le-3.6/native/common/jp_reference_queue.o build/temp.linux-ppc64le-3.6/native/common/jp_shorttype.o build/temp.linux-ppc64le-3.6/native/common/jp_stringclass.o build/temp.linux-ppc64le-3.6/native/common/jp_tracer.o build/temp.linux-ppc64le-3.6/native/common/jp_typemanager.o build/temp.linux-ppc64le-3.6/native/common/jp_value.o build/temp.linux-ppc64le-3.6/native/common/jp_voidtype.o build/temp.linux-ppc64le-3.6/native/python/jp_pythonenv.o build/temp.linux-ppc64le-3.6/native/python/jp_pythontypes.o build/temp.linux-ppc64le-3.6/native/python/jpype_memory_view.o build/temp.linux-ppc64le-3.6/native/python/pyjp_array.o build/temp.linux-ppc64le-3.6/native/python/pyjp_class.o build/temp.linux-ppc64le-3.6/native/python/pyjp_field.o build/temp.linux-ppc64le-3.6/native/python/pyjp_method.o build/temp.linux-ppc64le-3.6/native/python/pyjp_module.o build/temp.linux-ppc64le-3.6/native/python/pyjp_monitor.o build/temp.linux-ppc64le-3.6/native/python/pyjp_proxy.o build/temp.linux-ppc64le-3.6/native/python/pyjp_value.o -ldl -o build/lib.linux-ppc64le-3.6/_jpype.cpython-36m-powerpc64le-linux-gnu.so
위 메시지를 끝으로 빌드 완료됩니다. 빌드가 완료되었으니 설치를 해봅니다.
[root@p625-kvm1 JPype1-0.7.1]# /opt/anaconda3/bin/python setup.py install
creating dist
creating 'dist/JPype1-0.7.1-py3.6-linux-ppc64le.egg' and adding 'build/bdist.linux-ppc64le/egg' to it
removing 'build/bdist.linux-ppc64le/egg' (and everything under it)
Processing JPype1-0.7.1-py3.6-linux-ppc64le.egg
creating /opt/anaconda3/lib/python3.6/site-packages/JPype1-0.7.1-py3.6-linux-ppc64le.egg
Extracting JPype1-0.7.1-py3.6-linux-ppc64le.egg to /opt/anaconda3/lib/python3.6/site-packages
Adding JPype1 0.7.1 to easy-install.pth file
Installed /opt/anaconda3/lib/python3.6/site-packages/JPype1-0.7.1-py3.6-linux-ppc64le.egg
Processing dependencies for JPype1==0.7.1
Finished processing dependencies for JPype1==0.7.1
위와 같이 종료되면 현재 경로의 /opt/anaconda3 에 JPype1 이 잘 설치된 것입니다.
이제 konlpy를 whl파일로 설치합니다.
[root@p625-kvm1 cecuser]# pip install konlpy-0.5.2-py2.py3-none-any.whl
Processing ./konlpy-0.5.2-py2.py3-none-any.whl
Requirement already satisfied: JPype1>=0.7.0 in /opt/anaconda3/lib/python3.6/site-packages/JPype1-0.7.1-py3.6-linux-ppc64le.egg (from konlpy==0.5.2) (0.7.1)
Requirement already satisfied: colorama in /opt/anaconda3/lib/python3.6/site-packages (from konlpy==0.5.2) (0.3.9)
Requirement already satisfied: lxml>=4.1.0 in /opt/anaconda3/lib/python3.6/site-packages (from konlpy==0.5.2) (4.2.1)
Requirement already satisfied: beautifulsoup4==4.6.0 in /opt/anaconda3/lib/python3.6/site-packages (from konlpy==0.5.2) (4.6.0)
Requirement already satisfied: tweepy>=3.7.0 in /opt/anaconda3/lib/python3.6/site-packages (from konlpy==0.5.2) (3.8.0)
Requirement already satisfied: numpy>=1.6 in /opt/anaconda3/lib/python3.6/site-packages (from konlpy==0.5.2) (1.17.2)
Requirement already satisfied: requests-oauthlib>=0.7.0 in /opt/anaconda3/lib/python3.6/site-packages (from tweepy>=3.7.0->konlpy==0.5.2) (1.3.0)
Requirement already satisfied: PySocks>=1.5.7 in /opt/anaconda3/lib/python3.6/site-packages (from tweepy>=3.7.0->konlpy==0.5.2) (1.6.7)
Requirement already satisfied: requests>=2.11.1 in /opt/anaconda3/lib/python3.6/site-packages (from tweepy>=3.7.0->konlpy==0.5.2) (2.22.0)
Requirement already satisfied: six>=1.10.0 in /opt/anaconda3/lib/python3.6/site-packages (from tweepy>=3.7.0->konlpy==0.5.2) (1.12.0)
Requirement already satisfied: oauthlib>=3.0.0 in /opt/anaconda3/lib/python3.6/site-packages (from requests-oauthlib>=0.7.0->tweepy>=3.7.0->konlpy==0.5.2) (3.1.0)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/anaconda3/lib/python3.6/site-packages (from requests>=2.11.1->tweepy>=3.7.0->konlpy==0.5.2) (1.24.2)
Requirement already satisfied: certifi>=2017.4.17 in /opt/anaconda3/lib/python3.6/site-packages (from requests>=2.11.1->tweepy>=3.7.0->konlpy==0.5.2) (2019.9.11)
Requirement already satisfied: idna<2.9,>=2.5 in /opt/anaconda3/lib/python3.6/site-packages (from requests>=2.11.1->tweepy>=3.7.0->konlpy==0.5.2) (2.6)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /opt/anaconda3/lib/python3.6/site-packages (from requests>=2.11.1->tweepy>=3.7.0->konlpy==0.5.2) (3.0.4)
Installing collected packages: konlpy
Successfully installed konlpy-0.5.2
conda 명령어로 확인해보면, konlpy 가 설치되어 있음을 보실수 있습니다.
[root@p625-kvm1 cecuser]# conda list | grep konlpy
konlpy 0.5.2 pypi_0 pypi
konlpy 를 제대로 실행하기 위해, 우선 java-1.8.0-openjdk 가 설치되어있는지 확인해야 합니다. 만약 설치되어 있지 않으면, 아래 명령어로 설치합니다.
[root@p625-kvm1 ~]# yum install java-1.8.0-openjdk-devel.ppc64le
==============================================================================================
Package Arch Version Repository Size
==============================================================================================
Installing:
java-1.8.0-openjdk-devel ppc64le 1:1.8.0.222.b10-0.el7_6 local-rhn-server-os 7.9 M
Installing for dependencies:
giflib ppc64le 4.1.6-9.el7 local-rhn-server-iso-media 41 k
java-1.8.0-openjdk ppc64le 1:1.8.0.222.b10-0.el7_6 local-rhn-server-os 266 k
java-1.8.0-openjdk-headless ppc64le 1:1.8.0.222.b10-0.el7_6 local-rhn-server-os 31 M
libICE ppc64le 1.0.9-9.el7 local-rhn-server-iso-media 67 k
libSM ppc64le 1.2.2-2.el7 local-rhn-server-iso-media 39 k
libfontenc ppc64le 1.1.3-3.el7 local-rhn-server-iso-media 32 k
lksctp-tools ppc64le 1.0.17-2.el7 local-rhn-server-iso-media 89 k
pcsc-lite-libs ppc64le 1.8.8-8.el7 local-rhn-server-iso-media 36 k
ttmkfdir ppc64le 3.0.9-42.el7 local-rhn-server-iso-media 49 k
tzdata-java noarch 2019b-1.el7 local-rhn-server-os 187 k
xorg-x11-font-utils ppc64le 1:7.5-21.el7 local-rhn-server-iso-media 108 k
xorg-x11-fonts-Type1 noarch 7.5-9.el7 local-rhn-server-iso-media 521 k
(위 파일들이 설치됨)
[root@p625-kvm1 ~]# java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)
[root@p625-kvm1 ~]# /opt/anaconda3/bin/python
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:18:58)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from konlpy.tag import Kkma
>>> from konlpy.utils import pprint
>>> kkma=Kkma()
>>> pprint(kkma.sentences(u'네, 안녕하세요. 반갑습니다.'))
['네, 안녕하세요.', '반갑습니다.']
>>> pprint(kkma.nouns(u'질문이나 건의사항은 깃헙 이슈 트래커에 남겨주세요.'))
['질문', '건의', '건의사항', '사항', '깃헙', '이슈', '트래커']
이제 Konlpy를 사용하기 위한 준비가 되었습니다. 자세한 가이드는 Konlpy를 참조하여 사용하시면 됩니다. http://konlpy.org/ko/latest/
댓글 없음:
댓글 쓰기