簡體   English   中英

在Centos的虛擬環境中安裝python-ldap

[英]Install python-ldap in virtual environment on Centos

我設法在其他問題的幫助下成功安裝了python-ldap。

[root@test myproj]# python test.py
[]

但是在虛擬環境中時,我會看到“沒有名為ldap的模塊”

(venv)[root@test 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)[root@test 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個多小時,到處都是。 迫切需要幫助。

從您的錯誤消息看來,似乎沒有安裝gcc編譯器,但是編譯您嘗試安裝的python包是必需的。

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

yum install gcc

更進一步,“開發工具”組中還包含其他方便的開發包,包括gcc。 以root身份運行(或使用sudo),可以使用以下命令進行安裝:

 yum groupinstall “Development Tools”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM