2012-02-16 77 views
3

我想在python中编译和解码QR码的应用程序。我用编码器成功了,但是我没有找到用于在python中解码的库(但是zbar)。我在Windows 7系统中使用Python 2.7。我不能在我的系统中安装zbar。我安装了库所需的依赖模块,甚至在我试图安装它时,最终会出现很多错误 - 在zbar.h和zbarmodule.c中出现了很多的语法错误。我不明白为什么,也不知道问题是什么。QR码解码器库为python

我收到以下错误,同时安装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码库?

+1

什么是错误? – geoffspear 2012-02-16 11:29:52

+1

请过去的错误,让人们可以了解你在做什么 – Nilesh 2012-02-16 11:34:08

+0

我已经包括了错误,请通过并告诉我什么是问题。感谢@lafada和wooble。 – vijay 2012-02-17 03:48:51

回答

4

pyqrcode支持编码和解码QR码。

关于zbar,正如其他人所评论的,在不知道任何错误消息的情况下很难帮助您。

你是否从Windows二进制包或源代码安装zbar?

zbar有一个预编译的Windows二进制包可用here,它 也有二进制Python模块2.5和2.6可用here

关于zbar和安装通过看到这些zbar Installation Instructions

的需要基于上述链接以安装从源zbar和Python模块上采取如下所示的步骤的总结。

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

    添加from distutils.sysconfig import get_config_vars排队3和 以下参数添加到分机呼叫:

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

    其中zbarlibdirectory是像C:\zbar\lib和zbarincludedirectory是一样的东西C:\zbar\include

  6. 安装zbar和Python模块使用修改建立。PY

    python setup.py build --compiler=mingw32

    python setup.py install

至于Windows7的上安装pyqrcode,我没有那么做,但认为自己只是为相关标题下的来源的指示,先安装所有的依赖然后运行make并使用nmake进行安装,或者使用MinGW进行安装。

+0

感谢@Appleman的回答。现在如何在Windows中安装pyqrcode?我已经包含了我在zbar中得到的错误,我从源代码安装了它(使用easy_install从[zbar](http://pypi.python.org/pypi/zbar/0.10)打包到pypi) – vijay 2012-02-17 03:57:33