安装python ldap包时出错

问题描述

我正在尝试在 ubuntu 20.04 上安装 python-ldap

pip3 install python-ldap

它抱怨这个命令错误

x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -Qunused-arguments -Qunused-arguments -fPIC -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=3.3.1 -DLDAPMODULE_AUTHOR=python-ldap project -DLDAPMODULE_LICENSE=Python style -IModules -I/home/jlin/virtualenvs/pmas/include -I/usr/include/python3.8 -c Modules/LDAPObject.c -o build/temp.linux-x86_64-3.8/Modules/LDAPObject.o
    x86_64-linux-gnu-gcc: error: unrecognized command line option ‘-Qunused-arguments’
    x86_64-linux-gnu-gcc: error: unrecognized command line option ‘-Qunused-arguments’
    error: command 'x86_64-linux-gnu-gcc' Failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/jlin/virtualenvs/pmas/bin/python -u -c 'import io,os,sys,setuptools,tokenize; sys.argv[0] = '"'"'/tmp/pip-install-mw_idota/python-ldap_10d1d5b1c1324cd5b7e42a23e6d0db58/setup.py'"'"'; __file__='"'"'/tmp/pip-install-mw_idota/python-ldap_10d1d5b1c1324cd5b7e42a23e6d0db58/setup.py'"'"';f = getattr(tokenize,'"'"'open'"'"',open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"','"'"'\n'"'"');f.close();exec(compile(code,__file__,'"'"'exec'"'"'))' install --record /tmp/pip-record-dfol907l/install-record.txt --single-version-externally-managed --compile --install-headers /home/jlin/virtualenvs/pmas/include/site/python3.8/python-ldap Check the logs for full command output.

看起来有问题

x86_64-linux-gnu-gcc: error: unrecognized command line option ‘-Qunused-arguments’

在 Google 上搜索过,但没有多少关于这个典型错误的好的答案。

我尝试复制实际命令并在本地运行

/home/jlin/virtualenvs/pmas/bin/python -u -c 'import io,'"'"'exec'"'"'))' install --record /tmp/pip-record-dfol907l/install-record.txt --single-version-externally-managed --compile --install-headers /home/jlin/virtualenvs/pmas/include/site/python3.8/python-ldap

我得到以下输出

running install
running build
running install_egg_info
running egg_info
writing UNKNowN.egg-info/PKG-INFO
writing dependency_links to UNKNowN.egg-info/dependency_links.txt
writing top-level names to UNKNowN.egg-info/top_level.txt
reading manifest file 'UNKNowN.egg-info/SOURCES.txt'
writing manifest file 'UNKNowN.egg-info/SOURCES.txt'
removing '/home/jlin/virtualenvs/pmas/lib/python3.8/site-packages/UNKNowN-0.0.0-py3.8.egg-info' (and everything under it)
copying UNKNowN.egg-info to /home/jlin/virtualenvs/pmas/lib/python3.8/site-packages/UNKNowN-0.0.0-py3.8.egg-info
running install_scripts
writing list of installed files to '/tmp/pip-record-dfol907l/install-record.txt'
error: [Errno 2] No such file or directory: '/tmp/pip-record-dfol907l/install-record.txt'

它似乎试图写入 /tmp 文件夹中的文件,但它没有?

我尝试过的: 在 GOOGLE 和 SO 上搜索以安装额外建议的 apt 软件包,例如 build-essentials python3.8-dev libsasl2-dev python3-dev libldap2-dev libssl-dev 但没有解决我的问题。

解决方法

没有直接回答我自己的问题,但我认为有一个 python 包 python3-ldap 安装没有问题。