[Python]_01_python pip에서 UnicodeDecodeError 발생
1. 개요 |
CMD 에 pip install flask, 또는 requests 설치하려 했는데
사용자 컴퓨터 이름, 폴더 dir 사이에 멀티바이트 문자 ( 한글같은 ) 문자가 있을 시에는
ascii 코드 인코딩과 충돌되서 안됬던 오류
2. 본론 |
해결법은
http://blog.lyuwonkyung.com/windows-pipeseo-unicodedecodeerror-balsaeng-2/ 사이트 참조
1. Python이 설치된 경로(e.g. 나의 경우에는 C:\python)의 lib 디렉토리(윈도니까 폴더라고 해야하는 것인가)에 있는 site.py(c:\python\lib\site.py)를 열어 479, 490 라인의 |
def setencoding(): """Set the string encoding used by the Unicode implementation. The default is 'ascii', but if you're willing to experiment, you can change this.""" encoding = "utf-8" # Default value set by _PyUnicode_Init() # 요기! if 0: # Enable to support locale aware default string encodings. import locale loc = locale.getdefaultlocale() if loc[1]: encoding = loc[1] if 0: # Enable to switch off string to Unicode coercion and implicit # Unicode to string conversion. encoding = "undefined" if encoding != "utf-8": # 요기! # On Non-Unicode builds this will raise an AttributeError... sys.setdefaultencoding(encoding) # Needs Python Unicode build ! |
2. 같은 디렉토리의 ntpath.py를 열어 87번째 라인의 | |||||||||||||||||||||||||||||||||
|
3. 향후계획 |
python 실행시 열심히 삽질을 했던점, 공부하며서 유용하다 생각한점을 포스팅하겠습니다.