如何在 python 3.10 / windows 10 中成功导入 ldap3 (0.9.8.4)
how to successfully import ldap3 (0.9.8.4) in python 3.10 / windows 10
我正在使用 Python 3.10 并且想要建立 LDAP 连接。
所以我尝试了 ldap3(0.9.8.4).
我的项目在 venv 中运行。
我的代码:
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)
我得到的错误:
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'
我在只导入 sys、pyasn1 和 ldap3 时遇到同样的错误后使用了 from collections.abc import MutableMapping
。
我安装的模块:
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
可能有人可以帮助我建立 ldap 连接?
问候
合唱团
为此,我认为 Idap3 0.9.8.3 是 python10 的旧版本。如果您尝试最新的可以解决您的问题。
pip install ldap3
这对我来说很好用。并创建成功的连接。
如果您需要任何帮助,请在下方评论。
我正在使用 Python 3.10 并且想要建立 LDAP 连接。 所以我尝试了 ldap3(0.9.8.4).
我的项目在 venv 中运行。
我的代码:
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)
我得到的错误:
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'
我在只导入 sys、pyasn1 和 ldap3 时遇到同样的错误后使用了 from collections.abc import MutableMapping
。
我安装的模块:
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
可能有人可以帮助我建立 ldap 连接?
问候 合唱团
为此,我认为 Idap3 0.9.8.3 是 python10 的旧版本。如果您尝试最新的可以解决您的问题。
pip install ldap3
这对我来说很好用。并创建成功的连接。
如果您需要任何帮助,请在下方评论。