heroku无法安装zbar

时间:2013-10-28 20:21:38

标签: python django heroku zbar

我有一个Django应用程序,它使用zbar进行条形码识别。 它在我的开发人员计算机上工作正常,但当我尝试将其部署到Heroku时,我的提交被拒绝,并显示以下消息:

 Installing collected packages: zbar
         Running setup.py install for zbar
           building 'zbar' extension
           gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/app/.heroku/python/include/python2.7 -c zbarmodule.c -o build/temp.linux-x86_64-2.7/zbarmodule.o
           In file included from zbarmodule.c:24:
           zbarmodule.h:26:18: error: zbar.h: No such file or directory
           In file included from zbarmodule.c:24:
           /*many "undeclared" errors*/
            !     Push rejected, failed to compile Python app

pip install zbar在我的计算机上正常运行。 我填写了requirements.txt

cat requirements.txt
Django==1.5.5
PIL==1.1.7
dj-database-url==0.2.2
dj-static==0.0.5
django-toolbelt==0.0.1
gunicorn==18.0
psycopg2==2.5.1
static==0.4
wsgiref==0.1.2
zbar==0.10

任何人都可以帮助我吗? PS对不起我的写作错误。英语不是我的母语。

2 个答案:

答案 0 :(得分:2)

以这种方式检查:

  1. 创建heroku应用
  2. 创建下一个文件
    • app.py
      from pyzbar.pyzbar import decode
    • Procfile
      main: python app.py
    • requirements.txt
      pyzbar==0.1.8
    • Aptfile
      libzbar-dev
  3. 并添加下一个buildpack:
    • https://github.com/heroku/heroku-buildpack-apt.git
    • heroku/python
  4. 推送文件并在heroku上运行应用

来源:https://github.com/NaturalHistoryMuseum/pyzbar/issues/23#issuecomment-615893637

答案 1 :(得分:1)

zbar python包只是一个包装器。

您需要使用heroku buildpacks。 https://elements.heroku.com/buildpacks/generalui/heroku-buildpack-zbar 这个buildpack将在build

上安装zbar

或者,您也可以使用此: https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-apt

然后在项目的根目录中包含名为Aptfile的文件

libzbar-dev

它将使用libzbar-dev安装apt-get,因此当pip install zbar运行时,zbar将存在。

编辑:包括apt-get方法