---
title: "Python 安装编码报错 - UnicodeDecodeError"
author: "飞奔的熊猫"
date: "2014-09-17T16:40:37Z"
tags: []
categories: ["开源软件"]
slug: "python-unicodedecodeerror"
draft: false
lastmod: "2014-09-17T16:40:37Z"
id: 2117439
url: "https://runpanda.iteye.com/blog/2117439"
---

【基本介绍】
Python的编码问题，永无止境。

【错误介绍】

![](http://dl2.iteye.com/upload/attachment/0101/2047/c491cc2d-2ca8-3ba6-b7d2-c469af4cf9bd.jpg)

系统默认的编码是ascii

```linux
[root@vpn ~]# python
Python 2.6.8 (unknown, Nov  7 2012, 14:47:45) 
[gcc 4.1.2 20080704 (red hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.getdefaultencoding()
ascii
>>> 
```



在报错的文件中临时添加utf8 或者 gb18030

```linux

import sys 
reload(sys) 
sys.setdefaultencoding('utf8') 
```



【参考】
<http://blog.csdn.net/meylovezn/article/details/18080515>
<http://stackoverflow.com/questions/21129020/how-to-fix-unicodedecodeerror-ascii-codec-cant-decode-byte>