2017-09-07 117 views
0

我成功地在其他问题的帮助下安装了python-ldap。在Centos上的虚拟环境中安装python-ldap

[[email protected] myproj]# python test.py 
[] 

但是当虚拟环境中,我得到这个“无模块命名为LDAP”

(venv)[[email protected] myproj]# python test.py 
Traceback (most recent call last): 
    File "test.py", line 1, in <module> 
    import ldap 
ImportError: No module named ldap 

尝试安装 - 我得到一个长的错误信息,但我认为最重要的是这个

gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=2.4.43 -IModules -I/usr/include -I/usr/include/sasl -I/usr/local/include -I/usr/local/include/sasl -I/usr/include/python2.7 -c Modules/LDAPObject.c -o build/temp.linux-x86_64-2.7/Modules/LDAPObject.o 

unable to execute gcc: No such file or directory 

error: command 'gcc' failed with exit status 1 

试图安装依赖关系

(venv)[[email protected] socportal]# venv/bin/pip install python-dev 
Downloading/unpacking python-dev 
    Could not find any downloads that satisfy the requirement python-dev 
Cleaning up... 
No distributions at all found for python-dev 
Storing complete log in /root/.pip/pip.log 

我一直试图安装这个库超过5个小时,现在无处不在。 非常需要帮助。

回答

0

从你的错误信息看来,gcc编译器没有安装,但是需要编译你试图安装的python包。

以root身份运行(或使用sudo),与

yum install gcc 

去进一步安装它,发展其他方便的包存在于“开发工具”组,包括gcc英寸以根用户身份运行(或使用sudo),您可以将其安装在:

yum groupinstall “Development Tools” 
+0

这样做的确有用。非常感谢你!! – JMY

+0

请回答你的问题,请考虑验证答案。 – Lescurel

+0

我收到消息说:“感谢您的反馈!记录下少于15人的投票,但不要更改公开显示的帖子分数。” – JMY

相关问题