Python Kerberos-1.1.1.tar.gz在Windows上安装失败

时间:2014-01-25 00:35:53

标签: python authentication kerberos ntlm

我在基于Windows的环境(2003,win 7,2008 r2等)上运行Python,包括32位和64位版本。我最近不得不使用NTLM和Kerberos身份验证方案对面向内部的各种公司进行身份验证。

我使用'requests'模块成功进行了NTLM身份验证。具体来说,有一些文档讨论了Other Authentication的方法。安装'requests-ntlm'软件包效果很好!

不幸的是,我似乎无法让请求 - kerberos包工作。 requirements.txt表示需要kerberos-1.1.1包,但我无法构建/安装该包。

如果我尝试导入不带kerberos-1.1.1的requests-kerberos库,会发生什么:

>>> import requests
>>> from requests_kerberos import HTTPKerberosAuth
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "requests_kerberos\__init__.py", line 17, in <module>
    from .kerberos_ import HTTPKerberosAuth, REQUIRED, OPTIONAL, DISABLED
  File "requests_kerberos\kerberos_.py", line 1, in <module>
    import kerberos
ImportError: No module named kerberos
>>>

这是我尝试从我的一台WIN 7机器(使用python 2.6.5)构建kerberos-1.1.1软件包时的错误:

>python setup.py install --install-lib "C:\tmp"
running install
running build
running build_ext
building 'kerberos' extension
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox
/MD /W3 /GS- /DNDEBUG -IC:\Python26\ArcGIS10.0\include -IC:\Python26\ArcGIS10.0\
PC /Tcsrc/kerberos.c /Fobuild\temp.win32-2.6\Release\src/kerberos.obj '{' is not
 recognized as an internal or external command, operable program or batch file.
cl : Command line warning D9024 : unrecognized source file type ''{'', object fi
le assumed
cl : Command line warning D9027 : source file ''{'' ignored
cl : Command line warning D9024 : unrecognized source file type 'is', object fil
e assumed
cl : Command line warning D9027 : source file 'is' ignored
cl : Command line warning D9024 : unrecognized source file type 'not', object fi
le assumed
cl : Command line warning D9027 : source file 'not' ignored
cl : Command line warning D9024 : unrecognized source file type 'recognized', ob
ject file assumed
cl : Command line warning D9027 : source file 'recognized' ignored
cl : Command line warning D9024 : unrecognized source file type 'as', object fil
e assumed
cl : Command line warning D9027 : source file 'as' ignored
cl : Command line warning D9024 : unrecognized source file type 'an', object fil
e assumed
cl : Command line warning D9027 : source file 'an' ignored
cl : Command line warning D9024 : unrecognized source file type 'internal', obje
ct file assumed
cl : Command line warning D9027 : source file 'internal' ignored
cl : Command line warning D9024 : unrecognized source file type 'or', object fil
e assumed
cl : Command line warning D9027 : source file 'or' ignored
cl : Command line warning D9024 : unrecognized source file type 'external', obje
ct file assumed
cl : Command line warning D9027 : source file 'external' ignored
cl : Command line warning D9024 : unrecognized source file type 'command,', obje
ct file assumed
cl : Command line warning D9027 : source file 'command,' ignored
cl : Command line warning D9024 : unrecognized source file type 'operable', obje
ct file assumed
cl : Command line warning D9027 : source file 'operable' ignored
cl : Command line warning D9024 : unrecognized source file type 'program', objec
t file assumed
cl : Command line warning D9027 : source file 'program' ignored
cl : Command line warning D9024 : unrecognized source file type 'or', object fil
e assumed
cl : Command line warning D9027 : source file 'or' ignored
cl : Command line warning D9024 : unrecognized source file type 'batch', object
file assumed
cl : Command line warning D9027 : source file 'batch' ignored
cl : Command line warning D9024 : unrecognized source file type 'file.', object
file assumed
cl : Command line warning D9027 : source file 'file.' ignored
kerberos.c
\src\kerberosbasic.h(17) : fatal error C108
3: Cannot open include file: 'gssapi/gssapi.h': No such file or directory
error: command '"c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.ex
e"' failed with exit status 2 

我也试过了一台WIN 2008 R2服务器(使用python 2.7.2),但得到了一个不同的错误:

>python.exe "setup.py" install --
install-lib "C:\tmp"
running install
running build
running build_ext
building 'kerberos' extension
error: Unable to find vcvarsall.bat

我认为必须这样做,这些是从源代码构建的,需要某种C或C ++编译器,而我过去安装的大多数其他模块都很有用。任何建议表示赞赏!

2 个答案:

答案 0 :(得分:6)

我设法解决了这个问题。

  1. 安装$ pip install kerberos-sspi
  2. 从GitHub下载requests-kerberos ZIP
  3. 在'requests-kerberos / kerberos_.py'中,将第import kerberos行更改为import kerberos_sspi as kerberos
  4. 在'requirements.txt'中,删除'kerberos == 1.1.1'
  5. 运行$ python setup.py install
  6. 如果您想运行请求中的test_requests_kerberos.py - kerberos /您需要更改 import kerberos import kerberos_sspi as kerberos with patch.multiple('kerberos', ...)

    除此之外,您还需要更改所有出现的内容:

    with patch.multiple('kerberos_sspi', ...)
    

    使用:

    {{1}}

    这对我有用。

答案 1 :(得分:1)

安装Visual Studio 2012 Express可以解决的第二个问题,并在命令提示符下执行此命令:

> SET VS90COMNTOOLS=%VS110COMNTOOLS%

执行此命令后,我遇到了第一个问题。你解决了吗?