适用于python的QR Code解码器库 [英] QR Code decoder library for python

查看:110
本文介绍了适用于python的QR Code解码器库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用python构建可编码和解码QR码的应用程序.我使用编码器成功,但是找不到用于解码的库(但 zbar ) Python.我在Windows 7系统中使用Python 2.7.

I am trying to build an application in python that would encode and decode QR codes. I am successful with the encoder, but i don't find libraries(but zbar) for decoding in python. I am using Python 2.7 in a Windows 7 system.

我无法在系统中安装 zbar .我安装了库所需的依赖模块,即使到那时,每次尝试安装它时,我都会遇到很多错误-zbar.h和zbarmodule.c中有很多语法错误.我不明白为什么会这样,对问题到底是什么一无所知.

I am not able to install zbar in my system. I installed the dependency module required by the library and even then I end up with so many errors, whenever I try to install it - so many syntax errors in zbar.h and in zbarmodule.c. I don't understand why and clueless about what the problem is.

在安装zbar时出现以下错误

I get the following errors while installing zbar

C:\Users\vijay>easy_install zbar
Searching for zbar
Reading http://pypi.python.org/simple/zbar/
Reading http://zbar.sourceforge.net
Best match: zbar 0.10
Downloading http://pypi.python.org/packages/source/z/zbar/zbar-0.10.zip#md5=9e99
ef2f6b471131120982a0dcacd64b
Processing zbar-0.10.zip
Running zbar-0.10\setup.py -q bdist_egg --dist-dir c:\users\vijay\appdata\local\
temp\easy_install-hv_kag\zbar-0.10\egg-dist-tmp-sxhz3s
zbarmodule.c
C:\Python27\include\zbar.h(685) : error C2054: expected '(' to follow 'inline'
C:\Python27\include\zbar.h(687) : error C2085: 'zbar_processor_parse_config' : n
ot in formal parameter list
C:\Python27\include\zbar.h(687) : error C2143: syntax error : missing ';' before
'{'
C:\Python27\include\zbar.h(761) : error C2054: expected '(' to follow 'inline'
C:\Python27\include\zbar.h(763) : error C2085: 'zbar_processor_error_spew' : not
in formal parameter list
C:\Python27\include\zbar.h(763) : error C2143: syntax error : missing ';' before
'{'
C:\Python27\include\zbar.h(768) : error C2143: syntax error : missing '{' before
'const'
C:\Python27\include\zbar.h(777) : error C2054: expected '(' to follow 'inline'
C:\Python27\include\zbar.h(778) : error C2085: 'zbar_processor_get_error_code' :
not in formal parameter list
C:\Python27\include\zbar.h(778) : error C2143: syntax error : missing ';' before
'{'
C:\Python27\include\zbar.h(882) : error C2054: expected '(' to follow 'inline'
C:\Python27\include\zbar.h(884) : error C2085: 'zbar_video_error_spew' : not in
formal parameter list
C:\Python27\include\zbar.h(884) : error C2143: syntax error : missing ';' before
'{'
C:\Python27\include\zbar.h(889) : error C2143: syntax error : missing '{' before
'const'
C:\Python27\include\zbar.h(897) : error C2054: expected '(' to follow 'inline'
C:\Python27\include\zbar.h(898) : error C2085: 'zbar_video_get_error_code' : not
in formal parameter list
C:\Python27\include\zbar.h(898) : error C2143: syntax error : missing ';' before
'{'
C:\Python27\include\zbar.h(968) : error C2054: expected '(' to follow 'inline'
C:\Python27\include\zbar.h(970) : error C2085: 'zbar_window_error_spew' : not in
formal parameter list
C:\Python27\include\zbar.h(970) : error C2143: syntax error : missing ';' before
'{'
C:\Python27\include\zbar.h(975) : error C2143: syntax error : missing '{' before
'const'
C:\Python27\include\zbar.h(984) : error C2054: expected '(' to follow 'inline'
C:\Python27\include\zbar.h(985) : error C2085: 'zbar_window_get_error_code' : no
t in formal parameter list
C:\Python27\include\zbar.h(985) : error C2143: syntax error : missing ';' before
'{'
C:\Python27\include\zbar.h(1050) : error C2054: expected '(' to follow 'inline'
C:\Python27\include\zbar.h(1052) : error C2085: 'zbar_image_scanner_parse_config
' : not in formal parameter list
C:\Python27\include\zbar.h(1052) : error C2143: syntax error : missing ';' befor
e '{'
C:\Python27\include\zbar.h(1141) : error C2054: expected '(' to follow 'inline'
C:\Python27\include\zbar.h(1143) : error C2085: 'zbar_decoder_parse_config' : no
t in formal parameter list
C:\Python27\include\zbar.h(1143) : error C2143: syntax error : missing ';' befor
e '{'
C:\Python27\include\zbar.h(1276) : error C2054: expected '(' to follow 'inline'
C:\Python27\include\zbar.h(1278) : error C2085: 'zbar_scan_rgb24' : not in forma
l parameter list
C:\Python27\include\zbar.h(1278) : error C2143: syntax error : missing ';' befor
e '{'
zbarmodule.c(65) : error C2143: syntax error : missing ';' before 'type'
zbarmodule.c(66) : error C2065: 'major' : undeclared identifier
zbarmodule.c(66) : error C2065: 'minor' : undeclared identifier
zbarmodule.c(68) : error C2065: 'major' : undeclared identifier
zbarmodule.c(68) : error C2065: 'minor' : undeclared identifier
zbarmodule.c(133) : error C2275: 'zbar_error_t' : illegal use of this type as an
expression
C:\Python27\include\zbar.h(121) : see declaration of 'zbar_error_t'
zbarmodule.c(133) : error C2146: syntax error : missing ';' before identifier 'e
i'
zbarmodule.c(133) : error C2065: 'ei' : undeclared identifier
zbarmodule.c(134) : error C2065: 'ei' : undeclared identifier
zbarmodule.c(134) : error C2065: 'ei' : undeclared identifier
zbarmodule.c(134) : error C2065: 'ei' : undeclared identifier
zbarmodule.c(135) : error C2065: 'ei' : undeclared identifier
zbarmodule.c(135) : error C2065: 'ei' : undeclared identifier
zbarmodule.c(136) : error C2065: 'ei' : undeclared identifier
zbarmodule.c(146) : error C2275: 'PyObject' : illegal use of this type as an exp
ression
    c:\python27\include\object.h(108) : see declaration of 'PyObject'
zbarmodule.c(146) : error C2065: 'mod' : undeclared identifier
zbarmodule.c(147) : error C2065: 'mod' : undeclared identifier
zbarmodule.c(151) : error C2065: 'mod' : undeclared identifier
zbarmodule.c(151) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(151) : warning C4024: 'PyModule_AddObject' : different types for fo
rmal and actual parameter 1
zbarmodule.c(152) : error C2065: 'mod' : undeclared identifier
zbarmodule.c(152) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(152) : warning C4024: 'PyModule_AddObject' : different types for fo
rmal and actual parameter 1
zbarmodule.c(153) : error C2065: 'mod' : undeclared identifier
zbarmodule.c(153) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(153) : warning C4024: 'PyModule_AddObject' : different types for fo
rmal and actual parameter 1
zbarmodule.c(154) : error C2065: 'mod' : undeclared identifier
zbarmodule.c(154) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(154) : warning C4024: 'PyModule_AddObject' : different types for fo
rmal and actual parameter 1
zbarmodule.c(155) : error C2065: 'mod' : undeclared identifier
zbarmodule.c(155) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(155) : warning C4024: 'PyModule_AddObject' : different types for fo
rmal and actual parameter 1
zbarmodule.c(156) : error C2065: 'mod' : undeclared identifier
zbarmodule.c(156) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(156) : warning C4024: 'PyModule_AddObject' : different types for fo
rmal and actual parameter 1
zbarmodule.c(157) : error C2065: 'mod' : undeclared identifier
zbarmodule.c(157) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(157) : warning C4024: 'PyModule_AddObject' : different types for fo
rmal and actual parameter 1
zbarmodule.c(158) : error C2065: 'mod' : undeclared identifier
zbarmodule.c(158) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(158) : warning C4024: 'PyModule_AddObject' : different types for fo
rmal and actual parameter 1
zbarmodule.c(159) : error C2065: 'mod' : undeclared identifier
zbarmodule.c(159) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(159) : warning C4024: 'PyModule_AddObject' : different types for fo
rmal and actual parameter 1
zbarmodule.c(160) : error C2065: 'mod' : undeclared identifier
zbarmodule.c(160) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(160) : warning C4024: 'PyModule_AddObject' : different types for fo
rmal and actual parameter 1
zbarmodule.c(162) : error C2065: 'ei' : undeclared identifier
zbarmodule.c(162) : error C2065: 'ei' : undeclared identifier
zbarmodule.c(162) : error C2065: 'ei' : undeclared identifier
zbarmodule.c(163) : error C2065: 'ei' : undeclared identifier
zbarmodule.c(164) : error C2065: 'mod' : undeclared identifier
zbarmodule.c(164) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(164) : warning C4024: 'PyModule_AddObject' : different types for fo
rmal and actual parameter 1
zbarmodule.c(164) : error C2065: 'ei' : undeclared identifier
zbarmodule.c(164) : error C2065: 'ei' : undeclared identifier
zbarmodule.c(167) : error C2275: 'PyObject' : illegal use of this type as an exp
ression
    c:\python27\include\object.h(108) : see declaration of 'PyObject'
zbarmodule.c(167) : error C2065: 'dict' : undeclared identifier
zbarmodule.c(167) : error C2065: 'mod' : undeclared identifier
zbarmodule.c(167) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(167) : warning C4024: 'PyModule_GetDict' : different types for form
al and actual parameter 1
zbarmodule.c(169) : error C2065: 'dict' : undeclared identifier
zbarmodule.c(169) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(169) : warning C4024: 'zbarEnumItem_New' : different types for form
al and actual parameter 1
zbarmodule.c(171) : error C2065: 'dict' : undeclared identifier
zbarmodule.c(171) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(171) : warning C4024: 'zbarEnumItem_New' : different types for form
al and actual parameter 1
zbarmodule.c(183) : error C2275: 'PyObject' : illegal use of this type as an exp
ression
        c:\python27\include\object.h(108) : see declaration of 'PyObject'
zbarmodule.c(183) : error C2065: 'tp_dict' : undeclared identifier
zbarmodule.c(185) : error C2065: 'tp_dict' : undeclared identifier
zbarmodule.c(185) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(185) : warning C4024: 'zbarEnumItem_New' : different types for form
al and actual parameter 1
zbarmodule.c(186) : error C2065: 'tp_dict' : undeclared identifier
zbarmodule.c(186) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(186) : warning C4024: 'zbarEnumItem_New' : different types for form
al and actual parameter 1
zbarmodule.c(187) : error C2065: 'tp_dict' : undeclared identifier
zbarmodule.c(187) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(187) : warning C4024: 'zbarEnumItem_New' : different types for form
al and actual parameter 1
zbarmodule.c(188) : error C2065: 'tp_dict' : undeclared identifier
zbarmodule.c(188) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(188) : warning C4024: 'zbarEnumItem_New' : different types for form
al and actual parameter 1
zbarmodule.c(189) : error C2065: 'tp_dict' : undeclared identifier
zbarmodule.c(189) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(189) : warning C4024: 'zbarEnumItem_New' : different types for form
al and actual parameter 1
zbarmodule.c(190) : error C2065: 'tp_dict' : undeclared identifier
zbarmodule.c(190) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(190) : warning C4024: 'zbarEnumItem_New' : different types for form
al and actual parameter 1
zbarmodule.c(191) : error C2065: 'tp_dict' : undeclared identifier
zbarmodule.c(191) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(191) : warning C4024: 'zbarEnumItem_New' : different types for form
al and actual parameter 1
zbarmodule.c(192) : error C2065: 'tp_dict' : undeclared identifier
zbarmodule.c(192) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(192) : warning C4024: 'zbarEnumItem_New' : different types for form
al and actual parameter 1
zbarmodule.c(193) : error C2065: 'tp_dict' : undeclared identifier
zbarmodule.c(193) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(193) : warning C4024: 'zbarEnumItem_New' : different types for form
al and actual parameter 1
zbarmodule.c(194) : error C2065: 'tp_dict' : undeclared identifier
zbarmodule.c(194) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(194) : warning C4024: 'zbarEnumItem_New' : different types for form
al and actual parameter 1
zbarmodule.c(195) : error C2065: 'tp_dict' : undeclared identifier
zbarmodule.c(195) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(195) : warning C4024: 'zbarEnumItem_New' : different types for form
al and actual parameter 1
zbarmodule.c(196) : error C2065: 'tp_dict' : undeclared identifier
zbarmodule.c(196) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(196) : warning C4024: 'zbarEnumItem_New' : different types for form
al and actual parameter 1
zbarmodule.c(197) : error C2065: 'tp_dict' : undeclared identifier
zbarmodule.c(197) : warning C4047: 'function' : 'PyObject *' differs in levels o
f indirection from 'int'
zbarmodule.c(197) : warning C4024: 'zbarEnumItem_New' : different types for form
al and actual parameter 1
error: Setup script exited with error: command '"C:\Program Files (x86)\Microsof
t Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2

有人可以帮助我安装zbar或为我提供一个可用来解码QR码的库吗?

Can anyone help me with zbar installation or get me a library with which I can decode QR codes?

推荐答案

pyqrcode 支持对QR码进行编码和解码

pyqrcode supports encoding and decoding QR codes.

关于zbar,正如其他人所评论的那样,在不了解任何错误消息的情况下很难为您提供帮助.

Regarding zbar, as other have commented , it is difficult to help you without knowing any of the error messages.

您是从Windows二进制软件包还是从源代码安装zbar的?

Did you install zbar from Windows binary packages or source ?

zbar具有一个预构建的Windows二进制程序包,该程序包可用在这里 此处.

zbar has a prebuilt Windows binary package available here, it also has binary for the Python modules for 2.5 and 2.6 available here.

有关通过zbar安装的信息,请参见以下 zbar安装说明

Regarding zbar installation via see these zbar Installation Instructions

下面显示了根据上述链接从源代码安装zbar Python模块所需采取的步骤的摘要.

A summary of the steps you need to take based on the above link to install the zbar Python module from source is shown below.

  1. 安装zbar(最好从二进制文件此处)
  2. 安装 MinGW
  3. 将Zbar \ bin和MinGw \ bin(二进制安装目录)添加到Windows路径变量中
  4. 此处下载Zbar Python模块源并将其解压缩到一个临时文件夹
  5. 修改setup.py脚本以使用自定义zbar包含和库路径.

  1. Install zbar (preferably from the binary here)
  2. Install MinGW
  3. Add the Zbar\bin and MinGw\bin (binary installation directories) to your Windows Path Variable
  4. Download the Zbar Python module source from here and unzip it to a temporary folder
  5. Modify the setup.py script to use custom zbar include and library path.

在第3行中添加from distutils.sysconfig import get_config_vars,然后 将以下参数添加到扩展调用中:

Add from distutils.sysconfig import get_config_vars to line 3 and add the following parameters to the Extension call:

    library_dirs=["""zbarlibdirectory"""],
    include_dirs=[get_config_vars('INCLUDEDIR'),
                  get_config_vars('INCLUDEPY'),
                  """zbarincludedirectory"""]

其中zbarlib目录类似于C:\zbar\lib,而zbarinclude目录类似于C:\zbar\include

where zbarlibdirectory is something like C:\zbar\lib and zbarincludedirectory is something like C:\zbar\include

使用修改后的setup.py

Install zbar Python module using modified setup.py

python setup.py build --compiler=mingw32

python setup.py install

关于在Windows7上安装pyqrcode,我还没有这样做,但是相信您只是出于相关标题下的源代码说明,首先安装所有依赖项,然后使用nmake或MinGW的make运行make and make install.

As for installation pyqrcode on Windows7, I haven't done so yet but believe you just for the source instructions under the relevant heading, first installing all the dependencies then running make and make install either using nmake or make from MinGW.

这篇关于适用于python的QR Code解码器库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆