我已经在我的 centos 机器上安装了 python-ldap
和 flask-ldap
。
当我尝试导入 ldap 时,python 2.x 运行良好。但在 python 3.4 版本中它返回以下异常:
ImportError: No module named 'ldap'
我需要安装其他库才能在 python 3.4 版本中使用 ldap 吗?
任何帮助将不胜感激。
谢谢。
编辑:
我正在尝试通过以下命令在 python 3.4 版本中安装库:
python3.4 -m pip install python-ldap
python3.4 -m pip install Flask-LDAP
但我遇到以下异常:
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/
最佳答案
您必须为要使用的每个版本的 python 单独安装一个模块。如果您在 python 2.7 上安装它,它将不会安装在 python 3.6 上。即使你在3.6上安装了它,在3.7上也不会安装。您必须为要使用的每个 python 版本单独安装该模块。
阅读 this tutorial on pip troubleshooting 可能会有所帮助和 installing modules in Python 3 .
关于Python Shell 返回导入错误 : No module named 'ldap' exception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54025775/