Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
690 views
in Technique[技术] by (71.8m points)

authentication - Python Kerberos-1.1.1.tar.gz Install Failure on Windows

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.

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!

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.

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_kerberoskerberos_.py", line 1, in <module>
    import kerberos
ImportError: No module named kerberos
>>>

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:mp"
running install
running build
running build_ext
building 'kerberos' extension
c:Program Files (x86)Microsoft Visual Studio 9.0VCBINcl.exe /c /nologo /Ox
/MD /W3 /GS- /DNDEBUG -IC:Python26ArcGIS10.0include -IC:Python26ArcGIS10.0
PC /Tcsrc/kerberos.c /Fobuildemp.win32-2.6Releasesrc/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
srckerberosbasic.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.0VCBINcl.ex
e"' failed with exit status 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:mp"
running install
running build
running build_ext
building 'kerberos' extension
error: Unable to find vcvarsall.bat

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I managed to fix this problem.

  1. Install $ pip install kerberos-sspi
  2. Download requests-kerberos ZIP from GitHub
  3. In 'requests-kerberos/kerberos_.py', change the line import kerberos to import kerberos_sspi as kerberos
  4. In 'requirements.txt', delete 'kerberos==1.1.1'
  5. Run $ python setup.py install.

If you want to run test_requests_kerberos.py that is in requests-kerberos/ you need to change import kerberos with import kerberos_sspi as kerberos.

Beside that you need to change all occurrences of:

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

with:

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

That worked for me.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...