Python Buildpack - 致命错误:sasl/sasl.h文件或目录不存在

17
我在Bluemix应用程序中安装sasl时遇到以下错误:
       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.

我正在使用构建包:python 1.5.5

我的runtime.txt包含:python-3.5.0

如何在构建包中安装必要的标头?


更新:

看起来最新的云平台堆栈已经有了sasl库:https://github.com/cloudfoundry/cflinuxfs2/blob/1.119.0/cflinuxfs2/build/install-packages.sh#L98.

我如何在Bluemix上使用这个堆栈?


很遗憾,您无法控制堆栈的版本,只能等待Bluemix更新他们的版本。 - opiethehokie
谢谢你的更新。它鼓励我寻找一个解决方案,我成功地处理了这个问题。 - Chris Snow
3个回答

46

在安装sasl之前,您可能需要安装一些系统库,请参考https://pypi.python.org/pypi/sasl/0.1.3

该库包含C++代码,需要安装一些额外的系统库。

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


2
我尝试在Ubuntu环境下安装SASL,但是遇到了OP的错误。然后我尝试了 apt-get install -y libsasl2-dev gcc python-dev 命令,接着安装了 pip install sasl==0.2.1,之后就没有再出现错误了。 - penny chan
这个解决方案 apt-get install -y libsasl2-dev gcc python-dev 对我也起作用了。非常感谢。 - florins
这个解决方案在我的Linux RHEL 7.5上有效。谢谢! - HAltos
这个解决方案帮我解决了安装 pip3 install 'apache-airflow[devel_hadoop]' 的问题。 :) - Bruno Campos

2
我的解决方案是使用pure-sasl,并从应用程序代码中安装imypla和thrift_sasl,而不是从我的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'])

我在我的Flask应用程序的视图中添加了以下代码:https://github.com/snowch/movie-recommender-demo/blob/master/web_app/app/main/views.py

-1

我遇到了类似的错误 -

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

你可以尝试这个帖子,它对我很有帮助 我无法安装python-ldap


感谢您的回答。不幸的是,在Cloud Foundry应用程序中,您无法运行操作系统软件包管理器来安装所需的库。 - Chris Snow

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接