简体   繁体   中英

Python Shell returns ImportError: No module named 'ldap' exception

i have installed python-ldap and flask-ldap on my centos machine.

when i try import ldap, python 2.x works good. but in python 3.4 version it returns following exception:

ImportError: No module named 'ldap'

any other libraries am i need to install to use ldap in python 3.4 version?

any help will be appreciated.

Thanks.

edit:

i am trying to install libraries in python 3.4 version by following command:

python3.4 -m pip install python-ldap

python3.4 -m pip install Flask-LDAP

but i am getting following exception:

Command "/usr/bin/python3.4 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-qvn41t9w/python-ldap/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-zev4yfdk/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-qvn41t9w/python-ldap/

You have to install a module separately for every version of python you intend to use. If you installed it on python 2.7 it will not be installed on python 3.6. Even if you installed it on 3.6, it would not be installed on 3.7. You will have to separately install the module for every python version you intend to use it on.

It may help to read this tutorial on pip troubleshooting and installing modules in Python 3 .

resolved it by ensuring node is subscribed to repo first. Then searched for available modules: yum search python3 | grep ldap installed preferred module: yum install -y python3-ldap.x86_64 NOTE: this is on RHEL8

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM