2014-01-25 31 views
7

我在基于Windows的环境(2003,win 7,2008 r2等)上都运行了Python和32位64位风格的Python。我最近不得不使用NTLM和Kerberos身份验证方案对各种企业内部面向Web站点进行身份验证。Python Kerberos-1.1.1.tar.gz在Windows上安装失败

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

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

这里是如果我尝试导入请求的Kerveros库没有Kerberos的1.1.1发生了什么:

>>> 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 
>>> 

,这里是试图从建立Kerberos的1.1.1包时,我的错误我的WIN 7的机器(与Python 2.6.5)中的一个:

>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++编译器,而我以前安装的大多数其他模块工作得很好。任何建议表示赞赏!

回答

5

我设法解决这个问题。

  1. 从GitHub
  2. 安装$ pip install kerberos-sspi
  3. 下载requests-kerberos ZIP在 '请求的Kerveros/kerberos_.py',改变线import kerberosimport kerberos_sspi as kerberos
  4. 在 'requirements.txt',删除“的Kerberos = = 1.1.1'
  5. 运行$ python setup.py install

如果你想运行test_requests_kerberos.py是在请求的Kerveros /你需要改变 import kerberosimport kerberos_sspi as kerberos

除此之外,你需要改变所有出现:

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

有:

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

为我工作。

+0

Tahnk您的意见!它也适用于我! – user3233941

+0

只是为了对其他人进行调查,这显然是一种解决方法,但这个解决方法所需的原因是因为kerberos软件包在Windows上不受支持:http://calendarserver.org/ticket/ 828“没有补丁,这不会被看到,因为我们没有活跃的开发人员使用Windows,所以Windows不支持。” – JSoet

+0

我不相信这是什么意思是“缺少补丁,这不会得到看因为我们没有使用Windows的活跃开发者,所以Windows不受支持。“我几乎可以肯定,这是指您发现的网站是Mac软件站点,而不是Kerberos开发站点 – corporateWhore

1

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

> SET VS90COMNTOOLS=%VS110COMNTOOLS%

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