1920, 'LoadLibraryEx' Error

66 views
Skip to first unread message

Jacovb

unread,
May 5, 2020, 3:36:43 AM5/5/20
to PyInstaller
Im trying to use pyinstaller to turn a .py file into a .exe file, whenever I run it I get this:

104 INFO: PyInstaller: 3.6
105 INFO: Python: 3.8.2
105 INFO: Platform: Windows-10-10.0.18362-SP0
108 INFO: wrote C:\Users\jsimp\Desktop\pain\disable.spec
111 INFO: UPX is not available.
113 INFO: Extending PYTHONPATH with paths
['C:\\Users\\jsimp\\Desktop\\pain', 'C:\\Users\\jsimp\\Desktop\\pain']
113 INFO: checking Analysis
113 INFO: Building Analysis because Analysis-00.toc is non existent
114 INFO: Initializing module dependency graph...
118 INFO: Caching module graph hooks...
128 INFO: Analyzing base_library.zip ...
3565 INFO: Processing pre-find module path hook   distutils
3566 INFO: distutils: retargeting to non-venv dir 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.8_3.8.752.0_x64__qbz5n2kfra8p0\\lib'
5793 INFO: Caching module dependency graph...
5956 INFO: running Analysis Analysis-00.toc
Traceback (most recent call last):
  File "C:\Users\jsimp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\win32ctypes\pywin32\pywintypes.py", line 35, in pywin32error
    yield
  File "C:\Users\jsimp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
    return _dll._LoadLibraryEx(fileName, 0, flags)
  File "C:\Users\jsimp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\win32ctypes\core\cffi\_dll.py", line 23, in _LoadLibraryEx
    result = check_null(
  File "C:\Users\jsimp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\win32ctypes\core\cffi\_util.py", line 81, in __call__
    self._raise_error(function_name)
  File "C:\Users\jsimp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\win32ctypes\core\cffi\_util.py", line 92, in _raise_error
    raise exception
OSError: [WinError 1920] The file cannot be accessed by the system

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.752.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.752.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\jsimp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
  File "C:\Users\jsimp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\__main__.py", line 114, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\Users\jsimp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\__main__.py", line 65, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\Users\jsimp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\building\build_main.py", line 734, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "C:\Users\jsimp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\building\build_main.py", line 681, in build
    exec(code, spec_namespace)
  File "C:\Users\jsimp\Desktop\pain\disable.spec", line 6, in <module>
    a = Analysis(['disable.py'],
  File "C:\Users\jsimp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\building\build_main.py", line 244, in __init__
    self.__postinit__()
  File "C:\Users\jsimp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
    self.assemble()
  File "C:\Users\jsimp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\building\build_main.py", line 393, in assemble
    self.binaries.extend(bindepend.Dependencies([('', python, '')],
  File "C:\Users\jsimp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\depend\bindepend.py", line 228, in Dependencies
    for ftocnm, fn in getAssemblyFiles(pth, manifest, redirects):
  File "C:\Users\jsimp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\depend\bindepend.py", line 404, in getAssemblyFiles
    for assembly in getAssemblies(pth):
  File "C:\Users\jsimp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\depend\bindepend.py", line 355, in getAssemblies
    res = GetManifestResources(pth)
  File "C:\Users\jsimp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\utils\win32\winmanifest.py", line 1007, in GetManifestResources
    return winresource.GetResources(filename, [RT_MANIFEST], names, languages)
  File "C:\Users\jsimp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\utils\win32\winresource.py", line 170, in GetResources
    hsrc = win32api.LoadLibraryEx(filename, 0, LOAD_LIBRARY_AS_DATAFILE)
  File "C:\Users\jsimp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
    return _dll._LoadLibraryEx(fileName, 0, flags)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.752.0_x64__qbz5n2kfra8p0\lib\contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Users\jsimp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\win32ctypes\pywin32\pywintypes.py", line 37, in pywin32error
    raise error(exception.winerror, exception.function, exception.strerror)
win32ctypes.pywin32.pywintypes.error: (1920, 'LoadLibraryEx', 'The file cannot be accessed by the system')

I have tried running it as an admin in command prompt to no avail. Does anyone know a fix for this?

Amir Rossert

unread,
May 5, 2020, 6:35:37 AM5/5/20
to PyInstaller
Python 3.8.x is not officially supported yet, you can try to use the dev branch or use python 3.7.x or older.

Hartmut Goebel

unread,
May 5, 2020, 6:37:24 AM5/5/20
to pyins...@googlegroups.com
Am 05.05.20 um 06:23 schrieb Jacovb:
105 INFO: Python: 3.8.2

Pyhon 3.8 support still needs to be funded, see <https://github.com/pyinstaller/pyinstaller/issues/4311>

--
Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
Information Security Management, Security Governance, Secure Software Development

Goebel Consult, Landshut
http://www.goebel-consult.de

Blog: https://www.goe-con.de/blog/kamera-safari-durch-die-munchner-innenstadt
Kolumne: https://www.goe-con.de/hartmut-goebel/cissp-gefluester/2011-08-horrorszenario-bring-your-own-device

0x7B752811BF773B65.asc

Israel Brewster

unread,
May 5, 2020, 11:07:37 AM5/5/20
to PyInstaller
I've run into that error a number of times, but it always seems to happen when I'm running through the "git bash shell" rather than the system command prompt. Using a standard command prompt (not running as administrator) generally seems to work for me. Also, PyInstaller works fine with Python 3.8 in my experience.

Jamison Morse

unread,
May 6, 2020, 1:27:26 PM5/6/20
to PyInstaller
I had this issue as well. For me it was because I originally downloaded Python 3.8 through the Windows App Store instead of Python.org's website. The issue is the WindowsApps folder, and even when you set permissions when it is running the script it still did not seem to allow access. I had to uninstall Python, and then reinstall from Python.org and re-set up my Python environment.

Also -- once I did this you need to disable App Execution Aliases. You can do this by searching in the Windows Task Bar. It should be disabled for "App Installer python.exe" and "App Installer python3.exe".

After this, it should solve your issue -- at least it did for me. I was stumped for a very long time.
Reply all
Reply to author
Forward
0 new messages