0

i was working on the code for a ldap authentification when i get suddenly an import error for ldap3-2.9.1 That is my code:

import os
import socket
import sys
sys.path.append('C:\\Users\\User\\Python\\modules\\')
sys.path.append('C:\\Users\\User\\Python\\modules\\ldap3-2.9.1\\')

import pyasn1

from ldap3 import Server, Connection, SUBTREE, LEVEL, ALL

Here is the Error:

========= RESTART: C:\Users\User\Python\pyproj\project1\myldap2.py =========
Traceback (most recent call last):
  File "C:\Users\User\Python\pyproj\project1\myldap2.py", line 9, in <module>
    from ldap3 import Server, Connection, SUBTREE, LEVEL, ALL
ImportError: cannot import name 'Server' from 'ldap3' (C:\Users\User\Python\pyproj\project1\ldap3.py)

I dont changed anything in the paths, folderstructure, module and so on. I dont installed something new, or restarted the computer between the working state and the import error. the only changes i made where in the code.

i did a forced reinstall of ldap3 but it does not help.

i hope anyone knows about that kind of error

For verifying the Error i use a minimal code. I dont get Errors for other modules.

Chorum
  • 43
  • 2
  • 11
  • Was the change in the code that you didn't import `Server` before? – mkrieger1 Feb 03 '22 at 08:16
  • Or was the change that you renamed your file to `ldap3.py`? – mkrieger1 Feb 03 '22 at 08:17
  • oh my .... thanks for that ! yep it was the filename.... thanks again!! – Chorum Feb 03 '22 at 08:22
  • This is the canonical duplicate question for this problem: [Importing installed package from script raises "AttributeError: module has no attribute" or "ImportError: cannot import name"](https://stackoverflow.com/questions/36250353/importing-installed-package-from-script-raises-attributeerror-module-has-no-at) – mkrieger1 Feb 03 '22 at 09:09

0 Answers0