简体   繁体   中英

Can't install python-ldap via pip

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?

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/

您可以安装为python3实现的python-ldap

pip install python3-ldap

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM