码迷,mamicode.com
首页 > 其他好文 > 详细

pip 安装pandas报UnicodeDecodeError: 'ascii' codec can't decode byte 0xd5错

时间:2017-06-17 12:15:47      阅读:801      评论:0      收藏:0      [点我收藏+]

标签:set   ext   sse   through   sdn   sys   win   cio   panda   

Python在window环境中通过pip安装pandas报标题这样的错,主要是因为python默认编码格式是:ascii

在https://www.python.org/dev/peps/pep-0100/文章中有如下介绍

 

 

Unicode Default Encoding

    The Unicode implementation has to make some assumption about the
    encoding of 8-bit strings passed to it for coercion and about the
    encoding to as default for conversion of Unicode to strings when
    no specific encoding is given.  This encoding is called <default
    encoding> throughout this text.

    For this, the implementation maintains a global which can be set
    in the site.py Python startup script.  Subsequent changes are not
    possible.  The <default encoding> can be set and queried using the
    two sys module APIs:

      sys.setdefaultencoding(encoding)
        --> Sets the <default encoding> used by the Unicode implementation.
            encoding has to be an encoding which is supported by the
            Python installation, otherwise, a LookupError is raised.

            Note: This API is only available in site.py!  It is
            removed from the sys module by site.py after usage.

      sys.getdefaultencoding()
        --> Returns the current <default encoding>.

    If not otherwise defined or set, the <default encoding> defaults
    to ‘ascii‘.  This encoding is also the startup default of Python
    (and in effect before site.py is executed).

    Note that the default site.py startup module contains disabled
    optional code which can set the <default encoding> according to
    the encoding defined by the current locale.  The locale module is
    used to extract the encoding from the locale default settings
    defined by the OS environment (see locale.py).  If the encoding
    cannot be determined, is unknown or unsupported, the code defaults
    to setting the <default encoding> to ‘ascii‘.  To enable this
    code, edit the site.py file or place the appropriate code into the
    sitecustomize.py module of your Python installation.

 

 



解决方法:在python/lib/site.py中加入  

import sys
reload(sys)
sys.setdefaultencoding(‘gbk‘)

 

问题就解决了。。。。。。。。。。。。

pip 安装pandas报UnicodeDecodeError: 'ascii' codec can't decode byte 0xd5错

标签:set   ext   sse   through   sdn   sys   win   cio   panda   

原文地址:http://www.cnblogs.com/jxldjsn/p/7039654.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!