【问题标题】:Python Kerberos-1.1.1.tar.gz Install Failure on WindowsPython Kerberos-1.1.1.tar.gz 在 Windows 上安装失败
【发布时间】:2014-02-16 04:11:48
【问题描述】:

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

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

不幸的是,我似乎无法让 requests-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++ 编译器有关,而我过去安装的大多数其他模块都运行良好。任何建议表示赞赏!

【问题讨论】:

    标签: python authentication kerberos ntlm


    【解决方案1】:

    我设法解决了这个问题。

    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

    如果你想运行 requests-kerberos/ 中的test_requests_kerberos.py,你需要改变 import kerberosimport kerberos_sspi as kerberos

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

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

    与:

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

    这对我有用。

    【讨论】:

    • 只是为了让其他人跟进这个问题,这显然是一种解决方法,但需要这种解决方法的原因是 Windows 不支持 kerberos 包:calendarserver.org/ticket/828 “没有补丁,这不会被关注,因为我们没有使用 Windows 的活跃开发者,所以不支持 Windows。”
    • 我不相信这就是“缺少补丁,这不会被关注,因为我们没有使用 Windows 的活跃开发人员,因此不支持 Windows。”我的意思是几乎可以肯定它指的是您发现的站点是一个 mac 软件站点,而不是一个 kerberos 开发站点
    【解决方案2】:

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

    &gt; SET VS90COMNTOOLS=%VS110COMNTOOLS%

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-26
      • 2013-05-07
      • 2018-02-24
      • 2012-06-16
      • 1970-01-01
      • 2020-02-25
      相关资源
      最近更新 更多