1

I've been receiving the following error message when trying to convert a .py file to a .exe file. Strangely, PyInstaller worked fine on an earlier version of this program that was in a different folder. I've been unable to find a solution, and I don't understand any of this well enough to make sense of the error message. Any help would be much appreciated.

C:\Users\janca\source\repos\Super Random Group Creator>pyinstaller --onefile -w the_random_group_creator.py
62 INFO: PyInstaller: 3.5
62 INFO: Python: 3.7.4
62 INFO: Platform: Windows-10-10.0.17763-SP0
62 INFO: wrote C:\Users\janca\source\repos\Super Random Group Creator\the_random_group_creator.spec
62 INFO: UPX is not available.
62 INFO: Extending PYTHONPATH with paths
['C:\\Users\\janca\\source\\repos',
 'C:\\Users\\janca\\source\\repos\\Super Random Group Creator']
62 INFO: checking Analysis
62 INFO: Building Analysis because Analysis-00.toc is non existent
62 INFO: Initializing module dependency graph...
78 INFO: Initializing module graph hooks...
78 INFO: Analyzing base_library.zip ...
3467 INFO: running Analysis Analysis-00.toc
3467 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\program files (x86)\microsoft visual studio\shared\python37_64\python.exe
3671 INFO: Caching module hooks...
3671 INFO: Analyzing C:\Users\janca\source\repos\Super Random Group Creator\the_random_group_creator.py
3795 INFO: Loading module hooks...
3795 INFO: Loading module hook "hook-encodings.py"...
3858 INFO: Loading module hook "hook-pydoc.py"...
3858 INFO: Loading module hook "hook-PySide2.py"...
4436 INFO: Loading module hook "hook-PySide2.QtCore.py"...
4639 INFO: Loading module hook "hook-PySide2.QtGui.py"...
4811 INFO: Loading module hook "hook-PySide2.QtNetwork.py"...
5248 INFO: Loading module hook "hook-PySide2.QtWidgets.py"...
5514 INFO: Loading module hook "hook-xml.py"...
5764 INFO: Looking for ctypes DLLs
5764 INFO: Analyzing run-time hooks ...
5764 INFO: Including run-time hook 'pyi_rth_pyside2.py'
5764 INFO: Looking for dynamic libraries
Traceback (most recent call last):
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 35, in pywin32error
    yield
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
    return _dll._LoadLibraryEx(fileName, 0, flags)
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\win32ctypes\core\ctypes\_util.py", line 42, in check_null
    raise make_error(function, function_name)
OSError: [WinError 2] The system cannot find the file specified.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\building\build_main.py", line 844, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\building\build_main.py", line 791, in build
    exec(code, spec_namespace)
  File "C:\Users\janca\source\repos\Super Random Group Creator\the_random_group_creator.spec", line 17, in <module>
    noarchive=False)
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\building\build_main.py", line 243, in __init__
    self.__postinit__()
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
    self.assemble()
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\building\build_main.py", line 567, in assemble
    redirects=self.binding_redirects))
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\depend\bindepend.py", line 231, in Dependencies
    for ftocnm, fn in getAssemblyFiles(pth, manifest, redirects):
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\depend\bindepend.py", line 407, in getAssemblyFiles
    for assembly in getAssemblies(pth):
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\depend\bindepend.py", line 358, in getAssemblies
    res = GetManifestResources(pth)
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\utils\win32\winmanifest.py", line 1005, in GetManifestResources
    return winresource.GetResources(filename, [RT_MANIFEST], names, languages)
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\utils\win32\winresource.py", line 168, in GetResources
    hsrc = win32api.LoadLibraryEx(filename, 0, LOAD_LIBRARY_AS_DATAFILE)
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
    return _dll._LoadLibraryEx(fileName, 0, flags)
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\contextlib.py", line 130, in __exit__
    self.gen.throw(type, value, traceback)
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 37, in pywin32error
    raise error(exception.winerror, exception.function, exception.strerror)
win32ctypes.pywin32.pywintypes.error: (2, 'LoadLibraryExW', 'The system cannot find the file specified.')

UPDATE: I copied the relevant source files to a different directory and ran PyInstaller. That worked. It seems like the problem has something to do with the .pyproj files that Visual Studio creates.

Daniel
  • 11
  • 1
  • 4
  • check the answer from here https://stackoverflow.com/questions/57932432/pyinstaller-win32ctypes-pywin32-pywintypes-error-2-loadlibraryexw-the-sys – MathanKumar Nov 06 '19 at 06:20

0 Answers0