Can't install python-ldap via pip
Asked Answered
G

3

6

I can't install python-ldap via pip, I get the following error:

$ sudo pip3.4 install python-ldap
Downloading/unpacking python-ldap
  Downloading python-ldap-2.4.19.tar.gz (138kB): 138kB downloaded
  Running setup.py (path:/tmp/pip_build_root/python-ldap/setup.py) egg_info for package python-ldap
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip_build_root/python-ldap/setup.py", line 53
        print name + ': ' + cfg.get('_ldap', name)
                 ^
    SyntaxError: invalid syntax
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip_build_root/python-ldap/setup.py", line 53

    print name + ': ' + cfg.get('_ldap', name)

             ^

SyntaxError: invalid syntax

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/python-ldap
Storing debug log for failure in /home/nima/.pip/pip.log

Any ideas how to resolve this?

Guitarist answered 11/4, 2015 at 21:9 Comment(0)
U
9

It seems that your python-ldap is implemented in Python-2.X but you're using Python-3.X (Print Is A Function in python 3). Therefore, you need to install a newer version of this library that supports Python-3.X or install the library in python-2.X which is not recommended.

You can install the proper version for Python-3.X though using following command:

# if pip3 is the default pip alias for python-3
pip3 install python3-ldap

# otherwise 
pip install python3-ldap

Also here is the link of PiPy package for further information. https://pypi.python.org/pypi/python3-ldap/0.9.8.4/

Unheardof answered 11/4, 2015 at 21:11 Comment(8)
Yea that's what I'm confused about because the library uses python3 to build via sources. (pyldap.readthedocs.org/en/latest/install.html) and on github it's said to only support python >= 3.3. I guess I will just build it from sources instead.Guitarist
@Guitarist it appears that python-ldap (which you tried to install with pip) and PyLDAP (the RTD and Github project you mentioned) are two entirely separate entities, hence the confusion. The package you want, PyLDAP, is not available for installation via pip/PyPI.Allergist
@Allergist hah you are correct, I messed up the two :DGuitarist
@Kasramvd I had an application running on python 2.7 which was using python-ldap . Now since we are upgrading to python 3.4 the module will ofcourse not work as you have mentioned. But will the methods previously implemented work after setting up python3-ldap. Huge version change problemFrazier
@TaraPrasadGurung It depends on the way that you're implemented those methods. If they don't have any conflict with Python-3.X it'll definitely work otherwise you might want to use libraries that automatically do that for you or at least enhance the process of converting, like docs.python.org/3.0/library/2to3.htmlUnheardof
@Kasramvd yes the upgrade is really a pain. So if I guess if I have not used anything that will make a conflict for example print usage and others than it's going to work fine. thanks may be I will try to fix that way first. btw previously i was using import ldap so it must be now import ldap3 I hope. Thanks alotFrazier
@Kasramvd I tried to make it work this way (1). installed ldap3 (2) imported ldap3 .(3) Replaced every instance of ldap with ldap3 ( RESULT )But that didn't solve the problem ,the problem is AttributeError: module 'ldap3' has no attribute 'set_option' some of the methods are not available for ldap3. Now I may need to find the new methods and replace themFrazier
@TaraPrasadGurung Yes, you should look for the equivalent method. You can google the error first it there wasn't any answer you can ask your question in SO.Unheardof
A
4

You can install python-ldap which is implemented for python3

pip install python3-ldap
Adenosine answered 22/11, 2016 at 6:16 Comment(0)
N
0

Install winlapsearch

git clone https://github.com/ropnop/windapsearch.git
apt-get install python3-ldap
./windapsearch.py
Nuris answered 1/6, 2023 at 18:55 Comment(1)
Please don't just recommend a library without any information about what the library is or how, specifically, it can be used to solve this specific problem. Learn more.Lax

© 2022 - 2024 — McMap. All rights reserved.