#include <zbar.h> 1 error generated when running pip install zbar - python

I'm trying to run pip install zbar and for some reason I can't seem to find an answer to solve this dependency issue. Any help would be extremely appreciated. See traceback below:
Downloading/unpacking zbar
Downloading zbar-0.10.tar.bz2
Running setup.py
egg_info for package zbar
Installing collected packages: zbar
Running setup.py install for zbar
building 'zbar' extension
clang -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c zbarmodule.c -o build/temp.macosx-10.9-x86_64-2.7/zbarmodule.o
In file included from zbarmodule.c:24:
./zbarmodule.h:26:10: fatal error: 'zbar.h' file not found
#include <zbar.h>
^
1 error generated.
error: command 'clang' failed with exit status 1
running install
running build
running build_ext
building 'zbar' extension
creating build
creating build/temp.macosx-10.9-x86_64-2.7
clang -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c zbarmodule.c -o build/temp.macosx-10.9-x86_64-2.7/zbarmodule.o
In file included from zbarmodule.c:24:
./zbarmodule.h:26:10: fatal error: 'zbar.h' file not found
include <zbar.h>
^
1 error generated.
error: command 'clang' failed with exit status 1

In my case I was running Ubuntu and had to install libzbar-dev package:
sudo apt-get install libzbar-dev

$ brew install zbar
and after that
$ pip install zbar
The header files will then be found (zbar.h)

Encountered this problem again after 2 years... this is what worked for me
LDFLAGS=-L/usr/local/lib/ CPATH=/usr/local/include/ pip install zbar

In case others run into this issue aren't able to use pip to install zbar for python:
Install zbar: brew install zbar
Install PIL: brew install pillow
Download zbar source: https://pypi.python.org/pypi/zbar
Unzip zbar: tar -xjvf zbar-0.10.tar.bz2
Install: python setup.py install --user

I encountered this issue recently while attempting to launch a service locally from Mac OS in a virtual environment, that imports zbar in the python application. The service was still running python2.7.
Having the service running in a virtual environment I was unwilling to attempt anything that required global system changes.
I solved it by having to install zbar through Homebrew (globally). Then exporting flags or implicit rules used in the C compiling "recipe" to the virtual environment. Finally I installed a similar library to the zbar dependancy in the virtual environment.
$ brew install zbar
Then when sourced in the virtual environment I do the following to change the implicit rules in the c compilation recipe:
$ export LDFLAGS="-L$(brew --prefix zbar)/lib"
$ export CFLAGS="-I$(brew --prefix zbar)/include"
Finally I install a light version of zbar inside the venv:
$ pip install zbarlight
After the above, with the additional dependancy of pyzbar below included in my requirements.txt I am able to import zbar with python2.7 in the virtual environment.
pyzbar==0.1.7
Testing the import in the virtual environment:
$ python
>>> import zbar
>>>
Hope this helps someone in the future. I struggled quite a bit in getting this to work and resources regarding zbar are fairly scarce.

Related

Error Installing Kivy On Ubuntu

kivy/graphics/svg.pyx:469:9: 'reload' already defined
building 'kivy.graphics.svg' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Ikivy/include -Ikivy/include -I/usr/include/python2.7 -c kivy/graphics/svg.c -o build/temp.linux- x86_64-2.7/kivy/graphics/svg.o
kivy/graphics/svg.c:1:2: error: #error Do not use this file, it is the result of a failed Cython compilation.
#error Do not use this file, it is the result of a failed Cython compilation.
^
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
I am trying to install kivy on ubuntu 16.04 . When I execute " python setup.py build_ext --inplace -f " this instruction shows above error please help me...
It is likely that you cython version is incorrect.
For the current version of kivy (1.10.0), I've had success with cython==0.26. Install failed with 0.27.1 and 0.27.3 with the same error as yours.
So in your relevant anaconda environment, uninstall the current cython:
pip uninstall cython==0.2x.x
(give the correct version of your installed cython)
or
conda uninstall cython
Install cython==0.26:
pip install cython==0.26
(there doesn't seem to be a 0.26 version of cython in the linux64 anaconda channel)
Then: pip install kivy
IMHO much easier is to use apt-get or pip.
pip install Cython #pip or pip3
pip install Kivy
EDIT:
Of course install gcc
What's your cython version? you might want to update it to 0.24 or 0.25 to build kivy.
pip install -U cython==0.25
I am using Kivy on Ubuntu 16.04 LTS and used the following installation steps. Kivy examples is optional:
$ sudo add-apt-repository ppa:kivy-team/kivy
$ sudo apt-get update
$ sudo apt-get install python3-kivy
$ sudo apt-get install python-kivy-examples
$ sudo pip install --upgrade cython==0.26
For kivy version 1.10.0, cython must be 0.26

raspberry pi unable to install lxml pip package

I am trying to install lxml package after i installed BeautifulSoup4 package.
In the terminal i type:
sudo pip install lxml
This is what i get
sudo pip install lxml
Downloading/unpacking lxml
Running setup.py egg_info for package lxml
Building lxml version 3.6.1.
Building without Cython.
Using build configuration of libxslt 1.1.26
Building against libxml2/libxslt in the following directory: /usr/lib
Installing collected packages: lxml
Running setup.py install for lxml
Building lxml version 3.6.1.
Building without Cython.
Using build configuration of libxslt 1.1.26
Building against libxml2/libxslt in the following directory: /usr/lib
building 'lxml.etree' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -Isrc/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-armv9l-2.7/src/lxml/lxml.etree.o -w
And then it just hangs there at the last line for a very long long time, I have to exit by pressing CTRL+C.
Can someone tell me what it really means?
I then try pip freeze to see if the package is installed. No, it is not there.
well you could open python and try importing it. But if its python 3 try this
sudo apt-get install python3-lxml
else its
sudo apt-get install python-lxml

Ipython no readline available and pip install readline error

I installed ipython but it doesn't have the readline option. I first downloaded gnu readline and compiled and installed. DIdn't know whether it was a proper solution but was the first thing I thought of. It still wouldn't work to no avail with the same error as before:
WARNING: Readline services not available on this platform.
WARNING: The auto-indent feature requires the readline library
Then I tried using pip install readline and I get the error below. Any help would be appreciated:
running install
running build
running build_ext
building 'readline' extension
creating build
creating build/temp.linux-x86_64-2.6
creating build/temp.linux-x86_64-2.6/Modules
creating build/temp.linux-x86_64-2.6/Modules/2.x
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DHAVE_RL_CALLBACK -DHAVE_RL_CATCH_SIGNAL -DHAVE_RL_COMPLETION_APPEND_CHARACTER -DHAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK -DHAVE_RL_COMPLETION_MATCHES -DHAVE_RL_COMPLETION_SUPPRESS_APPEND -DHAVE_RL_PRE_INPUT_HOOK -I. -I/home/jspender/include/python2.6 -c Modules/2.x/readline.c -o build/temp.linux-x86_64-2.6/Modules/2.x/readline.o -Wno-strict-prototypes
creating build/lib.linux-x86_64-2.6
gcc -pthread -shared build/temp.linux-x86_64-2.6/Modules/2.x/readline.o readline/libreadline.a readline/libhistory.a -L/home/jspender/lib -lncurses -lpython2.6 -o build/lib.linux-x86_64-2.6/readline.so
/usr/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
----------------------------------------
Command /home/jspender/bin/python2.6 -c "import setuptools;__file__='/home/jspender/build/readline/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-lBWIOm-record/install-record.txt failed with error code 1
Storing complete log in /home/jspender/.pip/pip.log
tmaric is right. I had the same problem while installing iPython (Ubuntu 12.10, quantal, 32-bit). I was missing the dev version of the ncurses5 library. Try:
sudo apt-get install libncurses5-dev
and then installing the readline module again through pip
pip install readline
You have a linker error: library ncurses is not installed, or it is installed and the linker is searching for the wrong object file.
What platform/operating system are you using?
If you're running Linux/Unix, try:
locate libncurses
to see if the library is installed. If there are no libncurses*.{o,so,so.[0-9].[0-9]} files on your system, just install the library, and the readline. If there are some, then check which one is searched for by the readline compilation process, it could be that you just have to make a symbolic link, naming the library file properly.
I had the same issue with my Ubuntu 14.04 install trying to get some python libraries installed. iPython I believe requires readline which was failing for me until I ran the following commands.
sudo apt-get install python-dev
sudo apt-get install libncurses5-dev
sudo pip install readline

How can I install MySQL-python via pip/virtualenv for Python 2.5 on a Linux system with Python 2.6?

I am trying to set up a virtualenv for a Django project. It needs MySQL-python. I'm trying to replicate the production environment, which uses Python 2.5. My Ubuntu desktop has Python 2.5. I can install the Python 2.5 virtualenv with virtualenv --python=/usr/bin/python2.5 .... However when I try to pip install MySQL-python, I get this output:
$ pip install MySQL-python
Downloading/unpacking MySQL-python
Running setup.py egg_info for package MySQL-python
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
Installing collected packages: MySQL-python
Running setup.py install for MySQL-python
building '_mysql' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/include/mysql -I/usr/include/python2.5 -c _mysql.c -o build/temp.linux-i686-2.5/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -DUNIV_LINUX -DUNIV_LINUX
In file included from _mysql.c:29:
pymemcompat.h:10: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
I have installed the python-dev Ubuntu deb package, but that's for Python 2.6.
How else can I get MySQL-python installed?
I had this same problem on an Ubuntu box. Prior to installing MySQL-python via pip, I needed to compile the module and dependencies from source using the following command:
sudo apt-get build-dep python-mysqldb
see this article - http://theviceprogrammer.com/?p=238
Actually, found a solution, I enabled the Dead Snakes - old python version repository, then I could aptitude install python2.5-dev, and then pip install MySQL-python worked
Instead of using pip or easy_install, you can use apt-get:
sudo apt-get install python-mysqldb
Requiring from source as per adam's reply wasn't require for me, on Ubuntu 12.04 w/ Python 2.5

How to install SSL for python 2.5 on Debian Linux?

Question
How do I install SSL for Python 2.5 on Debian?
I have tried:
sudo easy_install ssl
But getting:
$ python setup.py build
looking for /usr/include/openssl/ssl.h
looking for /usr/include/krb5.h
running build
running build_py
running build_ext
building 'ssl._ssl2' extension
creating build/temp.linux-i686-2.5
creating build/temp.linux-i686-2.5/ssl
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I./ssl/2.5.1 -I/usr/include/python2.5 -c ssl/_ssl2.c -o build/temp.linux-i686-2.5/ssl/_ssl2.o
In file included from ssl/_ssl2.c:75:
./ssl/2.5.1/socketmodule.h:45:33: error: bluetooth/bluetooth.h: No such file or directory
./ssl/2.5.1/socketmodule.h:46:30: error: bluetooth/rfcomm.h: No such file or directory
./ssl/2.5.1/socketmodule.h:47:29: error: bluetooth/l2cap.h: No such file or directory
./ssl/2.5.1/socketmodule.h:48:27: error: bluetooth/sco.h: No such file or directory
In file included from ssl/_ssl2.c:75:
./ssl/2.5.1/socketmodule.h:98: error: field ‘bt_l2’ has incomplete type
./ssl/2.5.1/socketmodule.h:99: error: field ‘bt_rc’ has incomplete type
./ssl/2.5.1/socketmodule.h:100: error: field ‘bt_sco’ has incomplete type
error: command 'gcc' failed with exit status 1
Solution
sudo apt-get install libbluetooth-dev
sudo rm /usr/lib/python2.5/site-packages/ssl/__init__.pyc
For reference, you must install libbluetooth-dev.
In fact, you shouldn't compile your own version of python ssl module for several reasons:
you won't get automatic security updates of your python ssl module;
you won't get smooth upgrade path if you decide to upgrade Debian system on your server.
The best way to obtain python ssl module is to install it from official Debian repositories using apt-get:
apt-get install python-openssl
Hope this helps.

Categories