kakao / khaiii

Kakao Hangul Analyzer III
Apache License 2.0
1.4k stars 285 forks source link

(colab) 기분석 사전 재빌드 관련 질문드립니다. #93

Closed wwnight closed 4 years ago

wwnight commented 4 years ago

google colab에서 khaiii를 설치하고 기본 사전으로 분석까지 진행하였습니다.(설치와 실행은 정상입니다.) 이후 분석결과의 보완을 위해 사용자사전 추가를 하고자, preanal.my.txt를 만들어 colab에 업로드 하고, preanal.auto, preanal.manual 파일이 있는 /content/khaiii/rsc/src/로 파일을 옮겼습니다. 그리고 사전 빌드를 위하여 아래 코드를 실행하였습니다. !cd /content/build/ && make resource !cd /content/build && make install !cd /content/build && make package_python !pip install /content/build/package_python

그런데 마지막 install 줄에서 아래와 같은 에러가 발생합니다.

Processing ./build/package_python Building wheels for collected packages: khaiii Building wheel for khaiii (setup.py) ... error ERROR: Failed building wheel for khaiii Running setup.py clean for khaiii Failed to build khaiii Installing collected packages: khaiii Found existing installation: khaiii 0.4 Uninstalling khaiii-0.4: Successfully uninstalled khaiii-0.4 Running setup.py install for khaiii ... error Rolling back uninstall of khaiii Moving to /usr/local/lib/python3.6/dist-packages/khaiii-0.4.dist-info/ from /usr/local/lib/python3.6/dist-packages/~haiii-0.4.dist-info Moving to /usr/local/lib/python3.6/dist-packages/khaiii/ from /usr/local/lib/python3.6/dist-packages/~haiii ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-2fxerwe_/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-2fxerwe_/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-25n1q54n/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

에러를 어떻게 하면 해결할 수 있을지 도움 부탁드립니다. 감사합니다.

krikit commented 4 years ago

현재 python 패키지 설치 시 실행하는 setup.py 안에 cmake .. 명령을 수행하는 부분이 있습니다. 즉, /content/build의 상위 디렉터리가 khaiii 소스코드 위치와 같아야 정상적으로 설치가 진행될 것입니다.

따라서, /content/khaiii가 khaiii의 소스코드 위치라면, /content/build가 아니라 /content/khaiii/build에서 빌드를 진행하시고, 마지막 pip 명령어도 cd /content/khaiii/build/package_python && pip install .와 같이 실행하셔야 할 것 같습니다.

wwnight commented 4 years ago

답변 감사드립니다. 말씀해주신대로, build 폴더의 위치를 khaiii 폴더 안으로 옮겨서 다시 설치해 보았습니다. 설치코드를 아래와 같이 진행해보니 기본 분석은 잘 진행되습니다.

!git clone https://github.com/kakao/khaiii.git !pip install cmake !cd /content/khaiii/ && mkdir build !cd /content/khaiii/build && cmake /content/khaiii !cd /content/khaiii/build/ && make all !cd /content/khaiii/build/ && make resource !cd /content/khaiii/build && make install !cd /content/khaiii/build && make package_python !pip install /content/khaiii/build/package_python

다만, 재빌드 과정에서 이전과 동일한 에러가 발생했습니다. 재빌드 코드: !cd /content/khaiii/build/ && make resource !cd /content/khaiii/build && make install !cd /content/khaiii/build && make package_python !cd /content/khaiii/build/package_python && pip install .

에러코드는 아래와 같습니다. Processing /content/khaiii/build/package_python Building wheels for collected packages: khaiii Building wheel for khaiii (setup.py) ... error ERROR: Failed building wheel for khaiii Running setup.py clean for khaiii Failed to build khaiii Installing collected packages: khaiii Running setup.py install for khaiii ... error ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-76lvl_9j/setup.py'"'"'; file='"'"'/tmp/pip-req-build-76lvl_9j/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-hadd83ai/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

wwnight commented 4 years ago

pip install --upgrade setuptools pip wheel를 실행하고 !cd /content/khaiii/build/package_python && pip install .를 실행하면 에러메세지 중간에 아래와 같은 문구가 추가됩니다.

DEPRECATION: Could not build wheels for khaiii which do not use PEP 517. pip will fall back to legacy 'setup.py install' for these. pip 21.0 will remove support for this functionality. A possible replacement is to fix the wheel build issue reported above. You can find discussion regarding this at https://github.com/pypa/pip/issues/8368.

krikit commented 4 years ago

제가 colab에서 다음과 같은 절차로 설치를 해보니 한번에 에러 없이 설치가 됩니다.

!git clone https://github.com/kakao/khaiii.git
!pip install --upgrade setuptools pip wheel
!pip install cmake
!cd /content/khaiii/ && mkdir build
!cd /content/khaiii/build && cmake /content/khaiii
!cd /content/khaiii/build/ && make all
!cd /content/khaiii/build/ && make resource
!cd /content/khaiii/build && make install
!cd /content/khaiii/build && make package_python
!pip install /content/khaiii/build/package_python

아마 처음 설치하실 때 pip install --upgrade pip 명령을 먼저 사용하지 않고 wheel 빌드를 진행하면서, 구버전의 pip가 생성한 임시 빌드 디렉터리에 남아있는 중간 생성물로 인해 오류가 나지 않았을까 추측이 듭니다.

wwnight commented 4 years ago

설치 코드만 실행하면 정상작동이 되었는데, preanal.my.txt 파일을 추가한 후 동일 코드를 실행하면 계속 에러가 났습니다. 그래서 위키에 올려주신 기분석 사전만 별도로 빌드하는 방법을 사용했더니 성공하였습니다. 감사합니다.

그런데 preanal.auto 파일을 colab이나 window 환경에서 내용 수정을 할 수는 없는 것인지요? 중복 문제 때문에 auto파일을 수정하고 싶은데 방법을 잘 모르겠습니다.

krikit commented 4 years ago

preanal.auto 파일은 단순한 텍스트 파일입니다. 메모장이나 Atom 같은 텍스트 에디터로 열어서 편집하시면 됩니다.

wwnight commented 4 years ago

친절하게 답변해주셔서 정말정말 감사드립니다!!