我无法通过pip安装python-ldap,我收到以下错误:
$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
任何想法如何解决这个问题?
解决方法:
你的python-ldap似乎是在Python-2.X中实现的,但是你使用的是Python-3.X(Print Is A Function in python 3).因此,您需要安装支持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
此处还有PiPy包的链接以获取更多信息. https://pypi.python.org/pypi/python3-ldap/0.9.8.4/