问题描述
我在Windows上运行基于Python的环境中(2003年,胜7,2008 R2等),32位和64位的口味。我最近不得不验证到各类企业,面向内部的使用NTLM和Kerberos身份验证方案的Web站点。
I run Python on windows based environments (2003, win 7, 2008 r2, etc) both 32 and 64-bit flavors. I've recently had to authenticate to various corporate, internally facing web-sites using both NTLM and Kerberos authentication schemes.
我是成功的使用要求模块NTLM身份验证。特别是有一些文件讨论了。安装的要求,NTLM套餐伟大的工作!
I was successful with NTLM authentication using the 'requests' module. Specifically there is some documentation discussing ways for Other Authentication. Installing the 'requests-ntlm' packages worked great!
不幸的是,我似乎无法得到请求,Kerberos的封装工作。该requirements.txt表明Kerberos的1.1.1包是必需的,但我无法建立/安装该软件包。
Unfortunately I cannot seem to get the requests-kerberos package to work. The requirements.txt indicates that the kerberos-1.1.1 package is required, but I am unable to build/install that package.
下面是,如果我尝试导入的要求,Kerberos的库没有发生什么事了Kerberos的1.1.1:
Here is what happens if I try to import the requests-kerberos library without the 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
>>>
在这里,正试图从我的WIN 7的机器(与Python 2.6.5)中的一个建立Kerberos的1.1.1包时,我的错误:
And here is my errors when trying to build the kerberos-1.1.1 package from one of my WIN 7 machines (with 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)中的一个,却得到了一个不同的错误:
I also have tried one of my WIN 2008 R2 servers (with python 2.7.2), but get a different error:
>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 ++编译器,而大多数其他模块我已经安装在过去的工作太棒了。任何的建议是AP preciated!
I think this has to do that these are being built from source and need some sort of C or C++ compiler, whereas most other modules I've installed in the past worked great. Any advise is appreciated!
推荐答案
我设法解决这个问题。
- 安装
$ PIP安装Kerberos的SSPI
- 下载
请求 - 的Kerberos
邮政编码 - 在请求-的Kerberos / kerberos_.py,更改行
汇入Kerberos
到导入kerberos_sspi如Kerberos的
- 在requirements.txt,删除的Kerberos == 1.1.1
- 运行
$蟒蛇setup.py安装
。
从GitHub
- Install
$ pip install kerberos-sspi
- Download
requests-kerberos
ZIP from GitHub - In 'requests-kerberos/kerberos_.py', change the line
import kerberos
toimport kerberos_sspi as kerberos
- In 'requirements.txt', delete 'kerberos==1.1.1'
- Run
$ python setup.py install
.
如果你想运行 test_requests_kerberos.py
是在请求-的Kerberos /您需要更改汇入Kerberos
与进口kerberos_sspi如Kerberos的
。
If you want to run test_requests_kerberos.py
that is in requests-kerberos/ you need to changeimport kerberos
with import kerberos_sspi as kerberos
.
除了你需要改变所有出现的:
Beside that you need to change all occurrences of:
with patch.multiple('kerberos', ...)
与
with patch.multiple('kerberos_sspi', ...)
这是为我工作。
这篇关于Python的Kerberos的1.1.1.tar.gz在Windows上安装失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!