Python Forum

Full Version: .py to .exe using pyinstaller problem.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to compile my .exe from my .py file using pyinstaller. I am getting this error -
440 INFO: PyInstaller: 4.1.dev0
440 INFO: Python: 3.8.6rc1
442 INFO: Platform: Windows-10-10.0.19041-SP0
442 INFO: wrote C:\Users\Owner\Desktop\snake\snake.spec
452 INFO: UPX is not available.
459 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Owner\\Desktop\\snake', 'C:\\Users\\Owner\\Desktop\\snake']
540 INFO: checking Analysis
540 INFO: Building Analysis because Analysis-00.toc is non existent
540 INFO: Initializing module dependency graph...
544 INFO: Caching module graph hooks...
566 INFO: Analyzing base_library.zip ...
3953 INFO: Processing pre-find module path hook distutils from 'C:\\Users\\Owner\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python38\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
3960 INFO: distutils: retargeting to non-venv dir 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.8_3.8.1729.0_x64__qbz5n2kfra8p0\\lib'
6103 INFO: Caching module dependency graph...
6262 INFO: running Analysis Analysis-00.toc
Traceback (most recent call last):
  File "C:\Users\Owner\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\Owner\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\Owner\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\Owner\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\Owner\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.1729.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1729.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
  File "C:\Users\Owner\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\Owner\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\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\building\build_main.py", line 720, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\building\build_main.py", line 667, in build
    exec(code, spec_namespace)
  File "C:\Users\Owner\Desktop\snake\snake.spec", line 6, in <module>
    a = Analysis(['snake.py'],
  File "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\building\build_main.py", line 242, in __init__
    self.__postinit__()
  File "C:\Users\Owner\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\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\building\build_main.py", line 390, in assemble
    self.binaries.extend(bindepend.Dependencies([('', python, '')],
  File "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\depend\bindepend.py", line 224, in Dependencies
    for ftocnm, fn in getAssemblyFiles(pth, manifest, redirects):
  File "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\depend\bindepend.py", line 403, in getAssemblyFiles
    for assembly in getAssemblies(pth):
  File "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\depend\bindepend.py", line 354, in getAssemblies
    res = GetManifestResources(pth)
  File "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\utils\win32\winmanifest.py", line 1000, in GetManifestResources
    return winresource.GetResources(filename, [RT_MANIFEST], names, languages)
  File "C:\Users\Owner\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\Owner\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.1729.0_x64__qbz5n2kfra8p0\lib\contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Users\Owner\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')
Can someone tell me what I am doing wrong?

Thank you.
note that pyintsaller does not officially support 3.8 yet
however google-ing the error show multiple possible causes. For example - if the python was installed from windows app store, installing from python.org solves the problem for them.
So how did you install the python?
I installed Python 3.8.5 from Python.org
(Sep-13-2020, 05:09 PM)iNickster Wrote: [ -> ]I installed Python 3.8.5 from Python.org
That's not the version you use now.
(Sep-13-2020, 04:26 PM)iNickster Wrote: [ -> ]PythonSoftwareFoundation.Python.3.8_3.8.1729.0_x64__qbz5n2kfra8p0
This is the version from windows app store.
Look at Python 3.8 (3.6-3.7) and pip installation under Windows.
Under Fixing Path if needed and point to the version from Python.org.
Restart Pc and install Pyinstaller to this version and test again.
Pyinstaller now work fine for Python 3.8,have tested it several times.