Compile zbar for Python 3.x

2020-08-01 05:45发布

A few years ago I spent some time finding a way to make zbar work with Python 2.7 + Windows x64, and I posted this working solution: How to decode a QR-code image in (preferably pure) Python?

Now I notice pip install zbar still does not work out-of-the-box with Python 3.7, so I'm trying to compile it from source. Here is what I did:

  • Install "Microsoft Visual C++ Build Tools 2015" (see here)

  • Get the zbar source from: https://github.com/NaturalHistoryMuseum/ZBarWin64

  • msbuild zbar64.sln /p:PlatformToolset=v140, which worked and produced a file libzbar64-0.dll succesfully

  • copy it to /x64/Release/libzbar64-0.dll

  • go to Python/ and run build.bat but here it failed:

    zbarmodule.c(132): error C2143: syntax error: missing '{' before ''
    zbarmodule.c(136): error C2143: syntax error: missing '{' before '
    '
    zbarmodule.c(197): error C2065: 'PyInt_Type': undeclared identifier

I don't think the problem comes from zbar which compiles fine for everyone. Could it be that this version of zbar is not ok for Python 3.x?

Do you have a working solution to use the zbar library on Python 3.x + Windows x64?


PS: is it still maintained? The latest events seem to be in 2012 on the Mercurial repo, and it's not possible to post an issue on this Github repo nor this one.

1条回答
地球回转人心会变
2楼-- · 2020-08-01 06:09

To make zbar work for Python 3.x, you can install pyzbar

pip install pyzbar
查看更多
登录 后发表回答