[python-ldap] Mac OS X Lion & python-ldap

Michael Ströder michael at stroeder.com
Tue Feb 28 16:11:40 CET 2012


Mike,

I'm not familiar with Mac OS X at all.

But I don't see any reason why python-ldap should work in the Python shell but 
not in a Python script if invoked with the very same interpreter.

Maybe you should try to analyse the output of python -v and compare the paths 
used when importing python-ldap.

Ciao, Michael.

Mike Matz wrote:
> Good Morning,
>
> I am having difficulty getting python-ldap to work on Mac OS X 10.7.3. I
> installed python-ldap following the directions here
> <http://projects.skurfer.com/posts/2011/python_ldap_lion/>. I tested the
> module after installation and it appears to have installed correctly.
>
> mmatz$ python -c 'import ldap; print ldap.__version__'
> 2.4.8
>
> I was then able to use the module successfully from an interactive shell.
>
> mmatz$ python
> Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
> [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> import ldap
>  >>> server = "ldap://10.20.12.10:389"
>  >>> user = "some user"
>  >>> pwd = "some password"
>  >>> l = ldap.initialize(server)
>  >>> l.simple_bind_s(user, pwd)
> (97, [], 1, [])
>  >>> l.unbind_s()
>
> However, when I execute the same code from within a script, the script fails.
>
> mmatz$ python ldap.py
> Traceback (most recent call last):
> File "ldap.py", line 1, in <module>
> import ldap
> File "/Users/mmatz/Desktop/ldap.py", line 8, in <module>
> l = ldap.initialize(server)
> AttributeError: 'module' object has no attribute 'initialize'
>
> Any help on getting the python-ldap module to work from a script would be much
> appreciated.
> Thanks,
> Mike
>
>
>
>
>
> _______________________________________________
> python-ldap mailing list
> python-ldap at python.org
> http://mail.python.org/mailman/listinfo/python-ldap


-- 
Michael Ströder                 Klauprechtstr. 11
Dipl.-Inform.                   D-76137 Karlsruhe, Germany
Tel.: +49 721 8304316           Mobil: +49 170 2391920
E-Mail: michael at stroeder.com    http://www.stroeder.com


More information about the python-ldap mailing list