IT/Python

(임시) mac os python 설치, 가상환경 구축, konlpy, mecab

파프양 2021. 10. 19. 11:42
728x90

 

python 설치

 

python2 지원 종료,python2 시리즈의 EOL 

mac os 기본 설치되어 있음 

지원종료 안내:

 

2020.1.1. 부로 python2의 지원을 중단함. 이후에는 더 이상 더이상 버그 리포트나 수정, 지원 등 개선 작업이 이루어지지 않으므로 빠른 시일내에 python3로 넘어갈 것을 제안하고 있음 

 

이전 버전에 작성된 코드를 돌리는 것이 아니라면 python3를 설치하는게 좋을 것으로 보임

 

We are volunteers who make and take care of the Python programming language. We have decided that January 1, 2020, was the day that we sunset Python 2. That means that we will not improve it anymore after that day, even if someone finds a security problem in it. You should upgrade to Python 3 as soon as you can.

As of January 1st, 2020 no new bug reports, fixes, or changes will be made to Python 2, and Python 2 is no longer supported.

 

비고: 2000년에 python2가 개발되고 나서 큰 개선점을 발견하여 2006년 python3를 출시했으나 python2 이용자들을 위해 python2와 3을 동시에 유지시켜왔다. python3의 새롭고 좋은 기능들에도 불구하고 이용률이 저조하고, 인력의 한계 때문에 python3의 개선에 집중하기 위해 2015년 중단(EOL: End of Life)을 공지하고 빠른 시일내에 python3으로 업그레이드 할 것을 권고했다. 그러나 여전히 많은 이용자가 python2를 사용하고 있었고, 이에 따라 python2.x시리즈의 서비스 중단을 2020년으로 연기하였다. 

 

https://www.python.org/doc/sunset-python-2/

https://www.python.org/dev/peps/pep-0373/

 

 

python3  설치

1. 홈페이지 

https://www.python.org/downloads/

 

Download Python

The official home of the Python Programming Language

www.python.org

 

버전설정: 

pkg

 

 

2. terminal 이용

homebrew 

pip install 

pip upgrade

 

홈브류 설치

https://whitepaek.tistory.com/3

path 설정 

 

 

가상환경 구축

 

https://namwhis.tistory.com/entry/%EB%A7%A5macOS%EC%97%90%EC%84%9C%EC%9D%98-%ED%8C%8C%EC%9D%B4%EC%8D%ACPython-%EB%B2%84%EC%A0%84-%EA%B5%AC%EB%B6%84-%EB%B0%8F-%EA%B0%80%EC%83%81%ED%99%98%EA%B2%BDvenv%EC%82%AC%EC%9A%A9

 

 

맥(macOS)에서의 파이썬(Python) 버전구분(관리 pyenv) 및 가상환경(venv)사용

사용할 일이 있어 맥(macOS)에 설치된 파이썬의 상태를 확인해봅니다. $python -V Python 2.7.16 파이썬(Python) 2는 2020년 1월 1일로 공식적으로 지원 종료되었네요. Python 2.7 will retire in... 0Years 0Mon..

namwhis.tistory.com

 

 

 

---------------- konlpy 설치와 오류 --------------

konlpy설치하기

 

xcode, jdk(java developement kit)의 사전 설치 필요

 

tag module 중에서 mecab(형태소분석기)는 별도로 설치해줘야 함

https://joyae.github.io/2020-10-02-Mecab/

mac에서 사용할 때 오류 발생 mecab 설치 시 tweepy 버전 오류

 

오류 :tweepy  4.0 버전 업데이트에 의한 오류 (21.10월 기준)

해결: pip install tweepy == 3.10.0 명령어로 tweepy 버전 재 다운로드 후 해결 

 

from konlpy.tag import Mecab

tokenizer=Mecab()

tokenizer.morphs("분석할 문장") 

 

정상작동하는 것을 확인 

https://github.com/hexists/konlpy/wiki/konlpy-X-m1-silicon

 

GitHub - hexists/konlpy: Python package for Korean natural language processing.

Python package for Korean natural language processing. - GitHub - hexists/konlpy: Python package for Korean natural language processing.

github.com

https://joyae.github.io/2020-10-02-Mecab/

 

MeCab 설치 (Mac OS)

설치방법, 사용자사전추가방법

joyae.github.io

 

---------- jupyter  notebook 설치와 가상환경 사용하기 ---------------

 

가상환경 구동하고 주피터 노트북 실행한다고 노트북에서 가상환경으로 사용할 수 없음 

커널을 만들어 줘야함 

 

python -m ipykernel install --user --name 가상환경이름 --display-name "노트북에표시할이름"

 

참고: https://chancoding.tistory.com/86

 

Jupyter Notebook에 가상환경 Kernel 연결하기

목차 1. 아나콘다 가상 환경 만들기 아나콘다에 가상환경을 구성하도록 합니다. tf2.0 이라는 이름을 가진 파이썬 가상 환경을 만들었습니다. conda create -n tf2.0 python 자세한 내용은 이전 글을 통해

chancoding.tistory.com

 

728x90