pip 安装pandas报UnicodeDecodeError: 'ascii' codec can't decode byte 0xd5错
2016-07-20 14:45
363 查看
当python在window环境中通过pip安装pandas报标题这样的错,主要是因为python默认编码格式是:ascii
在https://www.python.org/dev/peps/pep-0100/文章中有如下介绍
解决方法:在python/lib/site.py中加入
import sys
reload(sys)
sys.setdefaultencoding('gbk')
问题就解决了。。。。。。。。。。。。
在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')
问题就解决了。。。。。。。。。。。。
相关文章推荐
- Text-Terminals on Linux
- 【SQLServer并发问题,先SELECT后UPDATE,避免并发脏读情况解决】
- 使用git pull文件时和本地文件冲突
- Combination Sum
- Tiling
- 静态路由和默认路由的理解
- POJ1276 Cash Machine 【解法二】
- 节约内存的读取数据库
- mac添加android的adb等工具到环境变量
- HDU-1846 Brave Game(巴什博奕)
- ajax请求json数据
- 初识DataFrames
- 1. IOS 9.3.3描述文件没了处理方法
- Spring源码解析(一) Spring事务控制之Hibernate
- [leetcode] 238. Product of Array Except Self
- JDBC
- HDU1213
- PHP+Ajax实现验证码的实时验证
- Spring中Quartz的配置
- STL之排序算法SORT 详细介绍