16

I've attempted to install Zbar for use with python 2.7.6 with Homebrew and pip (brew install zbar, then pip install zbar) but every time I import it, python crashes. Simply running:

#!/usr/bin/python

import zbar

lands me with this from the terminal:

:~ aj$ cd '/Users/aj/Documents/nlcc/check in/python/' && '/usr/bin/python'
'/Users/aj/Documents/nlcc/check in/python/test.py' 
&& echo Exit status: $? && exit 1
Segmentation fault: 11

Other modules (wxPython, Numpy, openCV) work just fine, but this one gives me the same crash every time. I've tried compiling and installing zbar from source, thinking it might be an issue with Homebrew (or maybe even pip), but that has its own set of issues that are quite honestly over my head (i.e. missing a dylib after running ./configure with options, and then the developer's setup.py). Anyone have any ideas? Sorry if I'm missing any relevant info, if anyone would like any other logs, just let me know how to retrieve them, and I'll post them as soon as I can, like I said, a lot of this is over my head.

AJM
  • 521
  • 4
  • 8
  • 1
    I found the answer, but I wanted to post it here anyway in case anyone has the same trouble I did. You can use the brew installation of zbar, but you have to install to python via: https://pypi.python.org/pypi/zbar using this patch: https://github.com/npinchot/zbar/commit/d3c1611ad2411fbdc3e79eb96ca704a63d30ae69. Also, use 'which python' in the terminal to make sure it's checking in the right directory. The only reliable way I found to do this was to 'edit ~/.bashrc' and add the /usr/local/ and /usr/local/bin/ and then 'source ~/.bashrc' whenever I opened a terminal. – AJM Feb 11 '14 at 06:26
  • Thanks, you should add the comment as response and accept it. Also, just fixing the link to the patch here: https://github.com/npinchot/zbar/commit/d3c1611ad2411fbdc3e79eb96ca704a63d30ae69 – lkraider Feb 13 '14 at 23:00

1 Answers1

36

I found the answer, but I wanted to post it here anyway in case anyone has the same trouble I did. You can use the brew installation of zbar, but you have to install to python via: pypi.python.org/pypi/zbar using this patch: https://github.com/npinchot/zbar/commit/d3c1611ad2411fbdc3e79eb96ca704a63d30ae69. Also, be sure to use which python in the terminal to make sure it's checking in the right directory. The only reliable way I found to make it do this was to edit ~/.bashrc and add the /usr/local/ and /usr/local/bin/ directories to it, and then source ~/.bashrc whenever I opened a terminal to install anything via pip or Homebrew.

Thanks for the tip about answering and accepting @lkraider

AJM
  • 521
  • 4
  • 8
  • Thank you, this was very helpful at a time of need! – Jérémie Oct 21 '14 at 00:47
  • @AJM could you give more details? I am having the same issue and I can't fix it – Inês Martins Dec 04 '15 at 17:19
  • 15
    To install patched python package use: `$ pip install git+https://github.com/npinchot/zbar.git` – aikoven Feb 05 '16 at 07:37
  • when i'm using qrtools in my mac, i encountered the same "exit code 139, sigseg" issue, after re-installed zbar with $pip install git+https://github.com/npinchot/zbar.git, it works. Thanks for your solution – longchuan Apr 26 '17 at 06:49