Search code examples
pythonldap

how to successfully import ldap3 (0.9.8.4) in python 3.10 / windows 10


i am using Python 3.10 and want to make a LDAP connection. so i tried ldap3(0.9.8.4).

my project runs in an venv.

my code:

import sys
sys.path.append('C:\\Users\\User\\Python\\pyproj\\project1\\Lib\\site-packages\\python3-ldap-0.9.8.4')
import pyasn1
from collections.abc import MutableMapping
from ldap3 import Connection


#server = Server('ip')
#con=Connection(server,'user','password',auto_bind=True)
#print(con)

the error i get:

Traceback (most recent call last):
  File "C:\Users\User\Python\pyproj\project1\myldap.py", line 5, in <module>
    from ldap3 import Connection
  File "C:\Users\User\Python\pyproj\project1\Lib\site-packages\python3-ldap-0.9.8.4\ldap3\__init__.py", line 254, in <module>
    from .core.server import Server
  File "C:\Users\User\Python\pyproj\project1\Lib\site-packages\python3-ldap-0.9.8.4\ldap3\core\server.py", line 35, in <module>
    from ..protocol.rfc4512 import SchemaInfo, DsaInfo
  File "C:\Users\User\Python\pyproj\project1\Lib\site-packages\python3-ldap-0.9.8.4\ldap3\protocol\rfc4512.py", line 33, in <module>
    from ..utils.conv import escape_bytes, json_hook, check_json_dict, format_json, check_escape
  File "C:\Users\User\Python\pyproj\project1\Lib\site-packages\python3-ldap-0.9.8.4\ldap3\utils\conv.py", line 30, in <module>
    from ..utils.ciDict import CaseInsensitiveDict
  File "C:\Users\User\Python\pyproj\project1\Lib\site-packages\python3-ldap-0.9.8.4\ldap3\utils\ciDict.py", line 31, in <module>
    class CaseInsensitiveDict(collections.MutableMapping):
AttributeError: module 'collections' has no attribute 'MutableMapping'

i used from collections.abc import MutableMapping after i've got the same error while only importing sys, pyasn1 and ldap3.

my installed modules:

altgraph==0.17.2
click @ file:///C:/Users/User/Python/modules/click-8.0.3-py3-none-any.whl
cmake @ file:///C:/Users/User/Python/modules/cmake-3.22.1-py2.py3-none-win_amd64.whl
colorama @ file:///C:/Users/User/Python/modules/colorama-0.4.4-py2.py3-none-any.whl
cycler @ file:///C:/Users/User/Python/modules/cycler-0.11.0-py3-none-any.whl
Cython @ file:///C:/Users/User/Python/modules/Cython-3.0.0a9-cp310-cp310-win_amd64.whl
Flask @ file:///C:/Users/User/Python/modules/Flask-2.0.2-py3-none-any.whl
fonttools @ file:///C:/Users/User/Python/modules/fonttools-4.29.0-py3-none-any.whl
future==0.18.2
imutils==0.5.4
itsdangerous @ file:///C:/Users/User/Python/modules/itsdangerous-2.0.1-py3-none-any.whl
Jinja2 @ file:///C:/Users/User/Python/modules/Jinja2-3.0.3-py3-none-any.whl
kiwisolver @ file:///C:/Users/User/Python/modules/kiwisolver-1.3.2-cp310-cp310-win_amd64.whl
MarkupSafe @ file:///C:/Users/User/Python/modules/MarkupSafe-2.0.1-cp310-cp310-win_amd64.whl
matplotlib @ file:///C:/Users/User/Python/modules/matplotlib-3.5.1-cp310-cp310-win_amd64.whl
numpy @ file:///C:/Users/User/Python/modules/numpy-1.22.1-cp310-cp310-win_amd64.whl
opencv-python @ file:///C:/Users/User/Python/modules/opencv_python-4.5.5-cp310-cp310-win_amd64.whl
packaging==21.3
paho-mqtt==1.6.1
pefile==2021.9.3
Pillow @ file:///C:/Users/User/Python/modules/Pillow-9.0.0-cp310-cp310-win_amd64.whl
pyasn1 @ file:///C:/Users/User/Python/modules/pyasn1-0.4.8-py2.py3-none-any.whl
pyasn1-modules @ file:///C:/Users/User/Python/modules/pyasn1_modules-0.2.8-py2.py3-none-any.whl
pyinstaller==5.0.dev0
pyinstaller-hooks-contrib==2021.5
pyparsing==3.0.7
python-dateutil @ file:///C:/Users/User/Python/modules/python_dateutil-2.8.2-py2.py3-none-any.whl
python3-ldap==0.9.8.4
pywin32-ctypes==0.2.0
scikit-build==0.12.0
six @ file:///C:/Users/User/Python/modules/six-1.16.0-py2.py3-none-any.whl
Werkzeug @ file:///C:/Users/User/Python/modules/Werkzeug-2.0.2-py3-none-any.whl

may be some can help me making a ldap connection ?

Greetings Chorum


Solution

  • For this, I think Idap3 0.9.8.3 is an older version of python10. If you try the latest could solve your problem. pip install ldap3 This is working fine for me. and creating a successful connection. if you need any help please comment below.