使用requests_ntlm库

时间:2015-09-10 03:17:52

标签: python python-requests py2exe

我使用下面的代码片段来进行Windows身份验证,它运行得非常好。但是,在创建exe时,我收到一个意外错误,其日志在下面给出。

日志:

 File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
   module = self._gcd_import(name)
 File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
   return self._find_and_load(name)
 File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 298, in _find_and_load
   getattr(parent_module, name.rpartition('.')[2])
 File "C:\Python34\lib\site-packages\py2exe\hooks.py", line 291, in __getattr__
   self.__finder.safe_import_hook(renamed, caller=self)
 File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
   self.import_hook(name, caller, fromlist, level)
 File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
   module = self._gcd_import(name)
 File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
   return self._find_and_load(name)
 File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 298, in _find_and_load
   getattr(parent_module, name.rpartition('.')[2])
 File "C:\Python34\lib\site-packages\py2exe\hooks.py", line 291, in __getattr__
   self.__finder.safe_import_hook(renamed, caller=self)
 File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
   self.import_hook(name, caller, fromlist, level)
 File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
   module = self._gcd_import(name)
 File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
   return self._find_and_load(name)
 File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 298, in _find_and_load
   getattr(parent_module, name.rpartition('.')[2])
 File "C:\Python34\lib\site-packages\py2exe\hooks.py", line 291, in __getattr__
   self.__finder.safe_import_hook(renamed, caller=self)
 File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
   self.import_hook(name, caller, fromlist, level)
 File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
   module = self._gcd_import(name)
 File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
   return self._find_and_load(name)
 File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 298, in _find_and_load
   getattr(parent_module, name.rpartition('.')[2])
 File "C:\Python34\lib\site-packages\py2exe\hooks.py", line 291, in __getattr__
   self.__finder.safe_import_hook(renamed, caller=self)
 File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
   self.import_hook(name, caller, fromlist, level)
 File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
   module = self._gcd_import(name)
 File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
   return self._find_and_load(name)
 File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 298, in _find_and_load
   getattr(parent_module, name.rpartition('.')[2])
 File "C:\Python34\lib\site-packages\py2exe\hooks.py", line 291, in __getattr__
   self.__finder.safe_import_hook(renamed, caller=self)
 File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
   self._info(name, caller, fromlist, level)
RuntimeError: maximum recursion depth exceeded

方式

def launch_url(self):
        url = self.url_entry.get()
        domain = self.domain_entry.get()
        username = self.username_entry.get()
        password = self.password_entry.get()
        self.response_entry.delete("1.0", END)
        if url == "" or domain == "" or username == "" or password == "":
            messagebox.showinfo("Domain scanner",message="All fields except \n response are mandatory. ")
        else:
            test_server_username = domain + "\\"+ username
            res = requests.get(url=url, auth=requests_ntlm.HttpNtlmAuth(test_server_username, password))
            self.response_entry.insert("1.0","RESPONSE \n" + res.text)

导入部分:

import sys
import requests
import requests_ntlm
from tkinter import *
from tkinter import messagebox

Py2Exe Setup.py

“”” 该模块用于从python创建exe Tkinter的。 “”“

from distutils.core import setup
import py2exe

data_files = [('', [r'hpXMLTools.ico']),]
setup(windows=[{'script': 'TestApp.py',
                'icon_resources': [(1, 'hpXMLTools.ico')],
               }],
      data_files=data_files,
      options={
          'py2exe':
              {
               'includes':['requests_ntlm']
              },

      },)

帮我解决这个问题,我使用的是Windows 7 64bit和python 3.4 32位。我也试过使用python 2.7和windows 7 32bit,这很好用。但我将代码移植到python3。有什么方法可以解决这个问题吗?

0 个答案:

没有答案