无法通过pip安装python-ldap

Nim*_*a G 4 python openldap python-3.x

我无法python-ldap通过pip 安装,出现以下错误:

$ 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
Run Code Online (Sandbox Code Playgroud)

任何想法如何解决这个问题?

Kas*_*mvd 5

看来您python-ldap是在Python-2.X中实现的,但是您正在使用Python-3.X(python 3中的Print Is A Function)。因此,您需要安装支持Python-3.X的该库的较新版本,或者不建议在python-2.X中安装该库。

您可以使用以下命令为Python-3.X安装正确的版本:

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

# otherwise 
pip install python3-ldap
Run Code Online (Sandbox Code Playgroud)

这也是PiPy软件包的链接,以获取更多信息。https://pypi.python.org/pypi/python3-ldap/0.9.8.4/