python buildpack - fatal error: sasl/sasl.h: No such file or directory
Asked Answered
S

3

18

I get the following error installing sasl in my Bluemix app:

       Installing collected packages: sasl, thrift-sasl
         Running setup.py install for sasl: started
           Running setup.py install for sasl: finished with status 'error'
           Command "/app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-9mi8225r/sasl/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-3l4o04ga-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-9mi8225r/sasl/
           running install
           running build_py
           creating build
           creating build/lib.linux-x86_64-3.5
           creating build/lib.linux-x86_64-3.5/sasl
           copying sasl/__init__.py -> build/lib.linux-x86_64-3.5/sasl
           running egg_info
           writing dependency_links to sasl.egg-info/dependency_links.txt
           writing top-level names to sasl.egg-info/top_level.txt
           warning: manifest_maker: standard file '-c' not found

           reading manifest file 'sasl.egg-info/SOURCES.txt'
           writing manifest file 'sasl.egg-info/SOURCES.txt'
           copying sasl/saslwrapper.cpp -> build/lib.linux-x86_64-3.5/sasl
           copying sasl/saslwrapper.pyx -> build/lib.linux-x86_64-3.5/sasl
           building 'sasl.saslwrapper' extension
           creating build/temp.linux-x86_64-3.5
           creating build/temp.linux-x86_64-3.5/sasl
           gcc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Isasl -I/app/.heroku/python/include/python3.5m -c sasl/saslwrapper.cpp -o build/temp.linux-x86_64-3.5/sasl/saslwrapper.o
           sasl/saslwrapper.h:22:23: fatal error: sasl/sasl.h: No such file or directory
            #include <sasl/sasl.h>
                                  ^
           compilation terminated.

I'm using the buildpack: python 1.5.5

My runtime.txt contains: python-3.5.0

How can I install the necessary headers in the buildpack?


Update:

It looks as though the latest cloud foundry stack has the sasl library: https://github.com/cloudfoundry/cflinuxfs2/blob/1.119.0/cflinuxfs2/build/install-packages.sh#L98.

How can I use this stack on Bluemix?

Smew answered 11/5, 2017 at 14:56 Comment(2)
You unfortunately can't control the version of the stack, you just have to wait for Bluemix to update theirs.Aggi
Thanks for the update. It encoraged me to look for a workaround with my application and I managed to move past this issue.Smew
S
2

The solution for me was to use pure-sasl and install imypla and thrift_sasl from application code rather than my requirements.txt:

try:
    import impyla 
except ImportError:
    print("Installing missing impyla")
    import pip
    pip.main(['install', '--no-deps', 'impyla'])

try:
    import thrift_sasl
except ImportError:
    print("Installing missing thrift_sasl")
    import pip
    # need a patched version of thrift_sasl.  see https://github.com/cloudera/impyla/issues/238
    pip.main(['install', '--no-deps',  'git+https://github.com/snowch/thrift_sasl'])

I added this code to a view in my flask application: https://github.com/snowch/movie-recommender-demo/blob/master/web_app/app/main/views.py

Smew answered 11/5, 2017 at 19:47 Comment(0)
L
47

Maybe you should install some system libraries before you can install sasl refer to https://pypi.python.org/pypi/sasl/0.1.3

This library contains C++ code, and will require some additional system libraries installed.

Debian/Ubuntu

apt-get install python-dev libsasl2-dev gcc

CentOS/RHEL

yum install gcc-c++ python-devel.x86_64 cyrus-sasl-devel.x86_64

Lw answered 12/7, 2017 at 9:51 Comment(4)
I was trying to install sasl in ubuntu env. It shows the OP's error. Then I tried apt-get install -y libsasl2-dev gcc python-dev. and then install pip install sasl==0.2.1, no more errorsPollock
This solution apt-get install -y libsasl2-dev gcc python-dev worked for me also. many thanksPinsky
The solution works for me on Linux RHEL 7.5. Thanks!!Pedicab
The solution resolve my problem to install pip3 install 'apache-airflow[devel_hadoop]'. :)Mhd
S
2

The solution for me was to use pure-sasl and install imypla and thrift_sasl from application code rather than my requirements.txt:

try:
    import impyla 
except ImportError:
    print("Installing missing impyla")
    import pip
    pip.main(['install', '--no-deps', 'impyla'])

try:
    import thrift_sasl
except ImportError:
    print("Installing missing thrift_sasl")
    import pip
    # need a patched version of thrift_sasl.  see https://github.com/cloudera/impyla/issues/238
    pip.main(['install', '--no-deps',  'git+https://github.com/snowch/thrift_sasl'])

I added this code to a view in my flask application: https://github.com/snowch/movie-recommender-demo/blob/master/web_app/app/main/views.py

Smew answered 11/5, 2017 at 19:47 Comment(0)
G
-1

I was having similar error -

In file included from sasl/saslwrapper.cpp:254:0:
sasl/saslwrapper.h:22:23: fatal error: sasl/sasl.h: No such file or directory
#include <sasl/sasl.h>
                       ^
compilation terminated.
error: command 'gcc' failed with exit status 1

Try this thread it was helpful for me I can't install python-ldap

Guaiacol answered 24/3, 2018 at 7:44 Comment(1)
Thanks for your answer. Unfortunately, on cloud foundry applications you aren’t able to run operating system package managers to install the required libraries.Smew

© 2022 - 2024 — McMap. All rights reserved.