生成二维码报错:IOError: encoder zip not available 分类: python学习 2015-05-06 19:43 107人阅读 评论(0) 收藏

环境:ubuntu14.04

今天想试试python生成二维码,找了篇博客试试:

http://www.jb51.net/article/58579.htm

1,先学着安装qrcode等:

$ sudo easy_install pil
$ sudo easy_install qrcode

2,在终端测试
$ qr "hello world" > test.png

报错:

... ...
IOError: encoder zip not available


百度,找到解决办法:http://codingnow.cn/language/208.html

1,安装需要的插件:

sudo apt-get install libjpeg8 libjpeg62-dev libfreetype6 libfreetype6-dev

2,查找PIL位置:

$ sudo easy_install -m pil
Searching for pil
Best match: PIL 1.1.7

Using /usr/local/lib/python2.7/dist-packages/PIL

... ...

3,删除PIL

sudo rm -r /usr/local/lib/python2.7/dist-packages/PIL

4,重装pil

sudo easy_install pil

5,测试

$ qr "hello world" > test.png

生成二维码成功;

再找个python的简单例子:http://www.cnblogs.com/linjiqin/p/4140455.html

import qrcode
img = qrcode.make('hello, qrcode')
img.save('test2.png')

运行后,同样生成二维码成功。


版权声明:本文为博主原创文章,未经博主允许不得转载。

posted @ 2015-05-06 19:43  冰菓折木  阅读(253)  评论(0编辑  收藏  举报