0

I have used below snippet to do the windows authentication and it is working perfectly fine. However while creating an exe I am getting an unexpected error and its log is given below.

Log:

 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

Method:

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 section:

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

Py2Exe Setup.py

""" This module is used to create the exe from python 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']
              },

      },)

Help me to resolve this issue, I am using windows 7 64bit and python 3.4 32 bit. I have also tried to exe using python 2.7 and windows 7 32bit , which worked fine. But I am porting the code to python3. Is there any way to resolve this issue?

Srikanth Bhandary
  • 1,707
  • 3
  • 19
  • 34
  • I had a problem with requests and PyInstaller because of ssh support. ssh settings wasn't in .py file. I solved it. Maybe it is or maybe it isn't, I got nothing from traceback. But you can try PyInstaller instead of py2exe as an option. – Speaking Code Sep 10 '15 at 04:01
  • try the solution from http://stackoverflow.com/questions/29649440/py2exe-runtimeerror-with-tweepy – Irfan Jun 14 '16 at 18:00

0 Answers0