Python ldap macOS值错误:选项

2024-04-26 04:34:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试在MacOSSierra上设置PythonLDAP。 当我尝试使用该模块时(在CentOS上运行的live env中工作) 我得到了下面的错误,经过搜索,这可能与在macOS上安装OpenLDAP或pythonldap有关,但是我还没有找到一篇文章来解释如何修复它。在

到目前为止,我已经通过homebrew安装了OpenLDAP,但尚未解决此问题:

错误:

^{1}$

我已经通过brew安装了openldap,如下所示

^{pr2}$

我已经用pip安装了pythonldap

alexs-mbp:~ alex$ sudo pip install python-ldap
The directory '/Users/alex/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/alex/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: python-ldap in /usr/local/lib/python2.7/site-packages
Requirement already satisfied: setuptools in /usr/local/lib/python2.7/site-packages (from python-ldap

Tags: piporandthe错误librarysudoldap
2条回答

我在macOS Sierra 10.12.4上使用MacPorts安装了python ldap(2.3.10_3),其中:

sudo port install py27-ldap

这也提取了OpenLDAP依赖关系(版本2.4.44_2)。在

我可以执行代码:

^{pr2}$

无错误(来自https://curl.haxx.se/ca/cacert-2017-01-18.pem的CA证书文件)

安装OpenLDAP和pythonldap遵循了哪些步骤?在

编辑:

我想我找到了something relevant,你能用我链接的证书文件试试上面的测试代码吗?在

我怀疑是permission/.pem格式错误

我的解决方案是,在执行pip install python-ldap操作时,需要包含基于brew的openldap库

您需要的信息可以通过执行brew info openldap找到,其中的内容如下:

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/brew/opt/openldap/lib
    CPPFLAGS: -I/usr/local/brew/opt/openldap/include

我的openldap安装在/usr/local/brew/opt/openldap/上,因此这需要一个命令,如:

^{pr2}$

尝试卸载PythonLDAP(pip uninstall python-ldap),然后运行brew info openldap,并在上面的命令中使用openldap lib和include directory的特定路径

注意:我也有一个问题,我的clang编译器没有找到macossdk sasl.h,但我不知道这是否只是我。通过在上面的命令行中添加 global-option=build_ext global-option="-I$(xcrun show-sdk-path)/usr/include/sasl"来解决这个问题

相关问题 更多 >