pip로 패키지 설치시 아래와 같이 UnicodeDecodeError가 발생하며 설치가 정상적으로 되지 않습니다.
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc0 in position 7: ordinal not in range(128)
이럴때는 .py 파일을 수정해주면 됩니다.
1. \lib\site.py의 setencoding()함수
encoding = "ascii"를 아래와 같이 encoding = "utf-8"로 변경
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 != "ascii":
# On Non-Unicode builds this will raise an AttributeError...
sys.setdefaultencoding(encoding) # Needs Python Unicode build !
1. \lib\npath.py의 join(path, *paths)함수
result_path = result_path + p_path를 result_path = result_path + p_path.encode('utf-8')로 변경
def join(path, *paths):
"""Join two or more pathname components, inserting "\\" as needed."""
result_drive, result_path = splitdrive(path)
for p in paths:
p_drive, p_path = splitdrive(p)
if p_path and p_path[0] in '\\/':
# Second path is absolute
if p_drive or not result_drive:
result_drive = p_drive
result_path = p_path
continue
elif p_drive and p_drive != result_drive:
if p_drive.lower() != result_drive.lower():
# Different drives => ignore the first path entirely
result_drive = p_drive
result_path = p_path
continue
# Same drive in different case
result_drive = p_drive
# Second path is relative to the first
if result_path and result_path[-1] not in '\\/':
result_path = result_path + '\\'
result_path = result_path + p_path.encode('utf-8')
## add separator between UNC and non-absolute path
if (result_path and result_path[0] not in '\\/' and
result_drive and result_drive[-1:] != ':'):
return result_drive + sep + result_path
return result_drive + result_path
'Programming > Python' 카테고리의 다른 글
pip UnicodeDecodeError 해결법 (0) | 2020.10.22 |
---|---|
Dictionary Attack (0) | 2020.03.04 |
ARP를 이용한 host scan (0) | 2020.02.24 |
ARP Spoofing (0) | 2020.02.24 |
cookie를 이용한 로그인 (0) | 2018.07.18 |
살아있는 호스트 IP 스캔하기 (0) | 2018.02.13 |
댓글0