I can’t seem to be able to get the python ldap module installed on my OS X Mavericks 10.9.1 machine.
Darwin 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64
I tried what was suggested here:
But when I try to use pip I get a different error
Modules/LDAPObject.c:18:10: fatal error: ‘sasl.h’ file not found
I also tried what was suggested here:
python-ldap OS X 10.6 and Python 2.6
But with the same error.
I am hoping someone could help me out here.
/usr/include appears to have moved
$ xcrun --show-sdk-path $ sudo ln -s <the_path_from_above_command>/usr/include /usr/include
Now run pip install!
I had the same problem. I’m using Macports on my Mac and I have cyrus-sasl2 installed which provides sasl.h in /opt/local/include/sasl/. You can pass options to build_ext using pip’s global-option argument. To pass the include PATH to /opt/local/include/sasl/sasl.h run pip like this:
pip install python-ldap --global-option=build_ext --global-option="-I/opt/local/include/sasl"
Alternatively you could point it to whatever the output from
xcrun --show-sdk-path provides. On my box that’s:
Then you need to determine the PATH to the sasl header files. For me that’s:
Let me know if that helps or you need a hand.
I used a combination of posts I found about this problem (including this one) to eventually come up with this (copied from a larger script):
export XC_SDK=$(xcrun --show-sdk-path) export USR_INC=$XC_SDK/usr/include export PATH=$USR_INC:$PATH echo "installing python-ldap" ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install python-ldap
You can test it with
python -c "import ldap"
The main reason I didn’t follow the advice of @hharnisc was that on my local machine /usr/local had not moved, so I just temporarily put $XC_SDK before it on the path, and that seems to work.
how to install PIL on Macosx 10.9?
using pieces from both @hharnisc and @mick-t answers.
pip install python-ldap --global-option=build_ext --global-option="-I$(xcrun --show-sdk-path)/usr/include/sasl"
In my particular case, I couldn’t simply use the
pip arguments noted in other answers because I’m using it with
tox to install dependencies from a requirements.txt file, and I need my tox.ini to remain compatible with non-Mac environments.
I was able to resolve this in much simpler fashion: exporting
CFLAGS such that it adds an include path to the sasl headers already installed by Xcode:
$ pip install python-ldap ... building '_ldap' extension creating build/temp.macosx-10.10-x86_64-2.7 creating build/temp.macosx-10.10-x86_64-2.7/Modules clang -fno-strict-aliasing -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=2.4.19 -IModules -I/opt/openldap-RE24/include -I/usr/include/sasl -I/usr/include -I/Users/bc/.pyenv/versions/2.7.10/include/python2.7 -c Modules/LDAPObject.c -o build/temp.macosx-10.10-x86_64-2.7/Modules/LDAPObject.o Modules/LDAPObject.c:18:10: fatal error: 'sasl.h' file not found #include <sasl.h> ^ 1 error generated. error: command 'clang' failed with exit status 1 $ export CFLAGS="-I$(xcrun --show-sdk-path)/usr/include/sasl" $ pip install python-ldap ... Successfully installed python-ldap-2.4.19
Depending on whether or not you use any userspace-friendly Python tools (I use pyenv), you may have to prefix your pip commands with
I got this error when running buildout.
I fixed it, first finding the sasl.h file:
mdfind -name sasl.h
then defining the corresponding CFLAGS environment variable:
and finally running buildout again.