#136 __loader__ is None error

open
nobody
None
5
2015-02-26
2014-07-29
No

Using py2exe 0.9.2.0 under Python 3.4.1, on Windows 8 64-bit.

When running build_exe on a build script I migrated from Python 2.6.4, I get ValueError: pywintypes.__loader__ is None

I have not found similar reports, so it may be a problem with the Python 3 environment I'm using, which we built here from source. It's working 100% on other fronts, however.

Full callstack:

D:\projects\thing1\python3\thing1\src\tools\tool_x>python -m py2exe.build_exe build.py
Traceback (most recent call last):
File "D:\projects\thing1\python3\thing1\output\python\lib\runpy.py", line 170, in _run_module_as_main
"main", mod_spec)
File "D:\projects\thing1\python3\thing1\output\python\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\build_exe.py", line 145, in <module>
main()
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\build_exe.py", line 141, in main
builder.analyze()
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\runtime.py", line 157, in analyze
self.mf.import_package(modname[:-2])
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 97, in import_package
self.safe_import_hook("%s.%s" % (name, modname))
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
module = self._gcd_import(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
return self._find_and_load(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 320, in _find_and_load
self._scan_code(module.code, module)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 358, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
module = self._gcd_import(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
return self._find_and_load(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 320, in _find_and_load
self._scan_code(module.code, module)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 358, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
module = self._gcd_import(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
return self._find_and_load(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 320, in _find_and_load
self._scan_code(module.code, module)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 358, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
module = self._gcd_import(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
return self._find_and_load(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 320, in _find_and_load
self._scan_code(module.code, module)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 358, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
module = self._gcd_import(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
return self._find_and_load(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 320, in _find_and_load
self._scan_code(module.code, module)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 365, in _scan_code
self._scan_code(c, mod)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 358, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
module = self._gcd_import(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
return self._find_and_load(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 320, in _find_and_load
self._scan_code(module.code, module)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 365, in _scan_code
self._scan_code(c, mod)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 358, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
module = self._gcd_import(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
return self._find_and_load(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 320, in _find_and_load
self._scan_code(module.code, module)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 358, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
module = self._gcd_import(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
return self._find_and_load(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 320, in _find_and_load
self._scan_code(module.code, module)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 358, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
module = self._gcd_import(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
return self._find_and_load(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 320, in _find_and_load
self._scan_code(module.code, module)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 365, in _scan_code
self._scan_code(c, mod)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 358, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
module = self._gcd_import(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
return self._find_and_load(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 320, in _find_and_load
self._scan_code(module.code, module)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 358, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
module = self._gcd_import(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
return self._find_and_load(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 320, in _find_and_load
self._scan_code(module.code, module)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 358, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
module = self._gcd_import(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
return self._find_and_load(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 320, in _find_and_load
self._scan_code(module.code, module)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 358, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
module = self._gcd_import(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
return self._find_and_load(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 320, in _find_and_load
self._scan_code(module.code, module)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 358, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
module = self._gcd_import(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
return self._find_and_load(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 320, in _find_and_load
self._scan_code(module.code, module)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 365, in _scan_code
self._scan_code(c, mod)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 358, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
module = self._gcd_import(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
return self._find_and_load(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 320, in _find_and_load
self._scan_code(module.code, module)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 358, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
module = self._gcd_import(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
return self._find_and_load(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 320, in _find_and_load
self._scan_code(module.code, module)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 365, in _scan_code
self._scan_code(c, mod)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 358, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
module = self._gcd_import(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
return self._find_and_load(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 304, in _find_and_load
self._load_module(loader, name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 336, in _load_module
self._add_module(name, mod)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\dllfinder.py", line 204, in _add_module
self.hook(mod)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\dllfinder.py", line 201, in hook
mth(self, mod)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\hooks.py", line 153, in hook_win32api
finder.import_hook("pywintypes")
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
module = self._gcd_import(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
return self._find_and_load(name)
File "D:\projects\thing1\python3\thing1\output\python\lib\site-packages\py2exe\mf3.py", line 297, in _find_and_load
loader = importlib.find_loader(name, path)
File "D:\projects\thing1\python3\thing1\output\python\lib\importlib__init.py", line 70, in find_loader
raise ValueError('{}.
loader is None'.format(name))
ValueError: pywintypes.
loader__ is None

Discussion

  • Thomas Heller

    Thomas Heller - 2014-07-30

    Can you provide a minimal test-case that triggers this behaviour, please?

     
  • Adam Pletcher

    Adam Pletcher - 2014-07-30

    In stripping this test down I pinpointed the problem. My Python 3 (+pywin32) environment was missing this folder:

    ..\site-packages\win32com\gen_py\

    Even though the only things to appear in there are auto-generated cache files, the fact this folder didn't exist on disk caused the above error. As soon as I created that empty directory py2exe ran with no issues.

    Normally the gen_py folder is created by pywin32_postinstall.py when those extensions are installed, but in our environment there is no install process, and we just manually add that stuff to our sitecustomize.py. I'll have to add something to make that empty folder if it's not present.

    Not sure if this info is useful but the ticket can be closed. Thank you.

     
  • Clay Sweetser

    Clay Sweetser - 2014-08-29

    I'm getting a similar error with a tool I'm developing. The tool uses wheezy.template to do some advanced string formatting, and py2exe (or rather, distutils) seems to be choking on it:

    Traceback (most recent call last):
      File "setup.py", line 5, in <module>
        windows=['main.py'])
      File "C:\Python34\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:\Python34\lib\distutils\dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Python34\lib\site-packages\py2exe\distutils_buildexe.py", line 188, in run
        self._run()
      File "C:\Python34\lib\site-packages\py2exe\distutils_buildexe.py", line 267, in _run
        builder.analyze()
      File "C:\Python34\lib\site-packages\py2exe\runtime.py", line 172, in analyze
        target.analyze(mf)
      File "C:\Python34\lib\site-packages\py2exe\runtime.py", line 74, in analyze
        modulefinder.run_script(self.script)
      File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 85, in run_script
        self._scan_code(mod.__code__, mod)
      File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 358, in _scan_code
        self.safe_import_hook(name, mod, fromlist, level)
      File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
        self.import_hook(name, caller, fromlist, level)
      File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
        module = self._gcd_import(name)
      File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
        return self._find_and_load(name)
      File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 320, in _find_and_load
        self._scan_code(module.__code__, module)
      File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 358, in _scan_code
        self.safe_import_hook(name, mod, fromlist, level)
      File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
        self.import_hook(name, caller, fromlist, level)
      File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
        module = self._gcd_import(name)
      File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
        return self._find_and_load(name)
      File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 320, in _find_and_load
        self._scan_code(module.__code__, module)
      File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 358, in _scan_code
        self.safe_import_hook(name, mod, fromlist, level)
      File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 135, in safe_import_hook
        self.import_hook(name, caller, fromlist, level)
      File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
        module = self._gcd_import(name)
      File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
        return self._find_and_load(name)
      File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 281, in _find_and_load
        self._gcd_import(parent)
      File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
        return self._find_and_load(name)
      File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 297, in _find_and_load
        loader = importlib.find_loader(name, path)
      File "C:\Python34\lib\importlib\__init__.py", line 70, in find_loader
        raise ValueError('{}.__loader__ is None'.format(name))
    ValueError: wheezy.__loader__ is None
    

    The file structure for wheezy.template is a bit odd - the 'wheezy' package is a directory with only a single folder in it, the 'template' package.

     
    Last edit: Clay Sweetser 2014-08-29
  • flutefreak7

    flutefreak7 - 2014-09-16

    Wait, don't close... I'm getting the same error, but apparently for different reasons because my gen_py folder exists. I'm not sure why I'm getting this error.

     
  • Thomas Heller

    Thomas Heller - 2014-09-16

    The problem with ValueError: xxx.__loader__ is None is the following:

    py2exe's modulefinder doesn't (yet) support PEP420 implicit namespace packages; and when the modulefinder encounters one (or a directory that could be a namespace package) then this error is raised. A short term solution would be to print a more meaingful error message; however I'm working on adding support for these PEP420 namespace packages.

    So, we should wait for the next py2exe release which will hopefully fix this...

     
  • flutefreak7

    flutefreak7 - 2014-09-16

    My problem went away when I deleted an import of win32.client that I was doing during the setup script. (I had a build_helper.py thing that updated the version number on a Word Doc which used win32.Dispatch to talk to Word...). Since pywintypes was never imported, it never had the opportunity to muck up the sys.modules and confuse py2exe (I'm assuming...).

    The next error I had did relate to Namespace modules... I had to add init.py to comtypes/gen because the gen folder was being picked up as a namespace module which later resulted in a key error when py2exe tried to get it's parent while trying to import it (again...I think...).

    All I know is I got py2exe working again for me. Yay!

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks