Anaconda:UnicodeDecodeError

Win10下安装Anaconda for python2.7,启动Anaconda Prompt时候出现以下错误:

Traceback (most recent call last):
File "C:\ProgramData\Anaconda2\Scripts\conda-script.py ", line 5, in
sys.exit(conda.cli.main())
File "C:\ProgramData\Anaconda2\lib\site-packages\conda\cli\main.py", line 176, in main
return handle_exception(e)
File "C:\ProgramData\Anaconda2\lib\site-packages\conda\exceptions.py", line 626, in handle_exception
print_unexpected_error_message(e)
File "C:\ProgramData\Anaconda2\lib\site-packages\conda\exceptions.py", line 588, in print_unexpected_error_message
stderrlogger.info(get_main_info_str(get_info_dict()))
File "C:\ProgramData\Anaconda2\lib\site-packages\conda\cli\main_info.py", line 162, in get_info_dict
from ..connection import user_agent
File "C:\ProgramData\Anaconda2\lib\site-packages\conda\connection.py", line 12, in
from requests import Session, version as REQUESTS_VERSION
File "C:\ProgramData\Anaconda2\lib\site-packages\requests_init.py", line 52, in
from .packages.urllib3.contrib import pyopenssl
File "C:\ProgramData\Anaconda2\lib\site-packages\requests\packages\urllib3\contrib\pyopenssl.py", line 47, in
from cryptography import x509
File "C:\ProgramData\Anaconda2\lib\site-packages\cryptography\x509_init
.py", line 7, in
from cryptography.x509.base import (
File "C:\ProgramData\Anaconda2\lib\site-packages\cryptography\x509\base.py", line 16, in
from cryptography.x509.extensions import Extension, ExtensionType
File "C:\ProgramData\Anaconda2\lib\site-packages\cryptography\x509\extensions.py", line 14, in
from asn1crypto.keys import PublicKeyInfo
File "C:\ProgramData\Anaconda2\lib\site-packages\asn1crypto\keys.py", line 22, in
from ._elliptic_curve import (
File "C:\ProgramData\Anaconda2\lib\site-packages\asn1crypto_elliptic_curve.py", line 51, in
from ._int import inverse_mod
File "C:\ProgramData\Anaconda2\lib\site-packages\asn1crypto_int.py", line 56, in
from ._perf._big_num_ctypes import libcrypto
File "C:\ProgramData\Anaconda2\lib\site-packages\asn1crypto_perf_big_num_ctypes.py", line 31, in
libcrypto_path = find_library('crypto')
File "C:\ProgramData\Anaconda2\lib\ctypes\util.py", line 53, in find_library
fname = os.path.join(directory, name)
File "C:\ProgramData\Anaconda2\lib\ntpath.py", line 85, in join
result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xa3 in position 0: ordinal not in range(128)

从最后的错误信息来看,是解码不对。解决方案如下:
从报错的第一行找到对应的文件:conda-script.py(运行conda env list的时候发生类似错误,不过报错的文件变成conda-env-script.py,解决方案相同),将其内容改为:

if __name__ == '__main__':
    import sys
    if sys.getdefaultencoding() != 'gbk':  
        reload(sys)  
        sys.setdefaultencoding('gbk')      
    import conda.cli
    sys.exit(conda.cli.main())

你可能感兴趣的:(Anaconda:UnicodeDecodeError)