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

来源:互联网 发布:vivo手机怎么开4g网络 编辑:程序博客网 时间:2024/05/22 21:53
  • 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://blog.csdn.net/edward_liang_/article/details/50440045
http://blog.sina.com.cn/s/blog_6c39196501013s5b.html
http://blog.csdn.net/u012226330/article/details/17611749

0 0
原创粉丝点击