2014-01-25 29 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%

執行此命令後,我有你的第一個問題一個問題。你解決了嗎?