红联Linux门户
Linux帮助

ubuntu下python2.7安装模块ascii不能解码错误解决方案

发布时间:2016-11-11 09:24:30来源:linux网站作者:VincentLuo91
ubuntu下python2.7 安装spp 模块(pip install spp)报错:
Traceback (most recent call last): File “/usr/bin/pip”, line 9, in
load_entry_point(‘pip==1.5.6’, ‘console_scripts’, ‘pip’)() File “/usr/lib/python2.7/dist-packages/pip/init.py”, line 248, in main
return command.main(cmd_args) File “/usr/lib/python2.7/dist-packages/pip/basecommand.py”, line 166, in
main
text = ‘\n’.join(complete_log) UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe6 in position 51: ordinal not in range(128)
估计是字符编码解码过程中导致的问题。
 
解决的办法:
在/usr/lib/python2.7/sitecustomize.py脚本中加上如下三行即可:
import sys
reload(sys)
sys.setdefaultencoding(‘utf-8’)
 
加入上述语句后,重新安装,发现又报错:
src/spp.c:4:20: fatal error: Python.h: 没有那个文件或目录 compilation
terminated. error: command ‘x86_64-Linux-gnu-gcc’ failed with exit
status 1
其实这个错误是一个间接,由其依赖引起。
 
解决的办法:
安装python-dev,这是Python的头文件和静态库包:
sudo apt-get install python-dev  
 
安装pip install captchaimage时候,又报如下错误:
captchaimage.c:12:22: fatal error: ft2build.h: 没有那个文件或目录 compilation
terminated. error: command ‘x86_64-linux-gnu-gcc’ failed with exit
status 1
 
解决的办法:
这是由于显示文字信息时还需要与字体相关的东西,解决方案:
sudo apt-get install libfreetype6-dev
 
安装pycurl-7.43.0报错:
File “setup.py”, line 107, in configure_unix
raise ConfigurationError(msg)
main.ConfigurationError: Could not run curl-config: [Errno 2] No such file or directory
 
解决方案:
sudo apt-get install libcurl4-openssl-dev
 
本文永久更新地址:http://www.linuxdiyf.com/linux/25903.html