-1

I had finished my project lately; but I want to convert to an exe so I used pyinstaller to convert, I installed it, it finished downloading, then I wrote the first line pyinstaller --onefile 'main.py' then I clicked enter;

it was analyzing everything and everything was ok until comes this error:

Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\amhma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
  File "C:\Users\amhma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\__main__.py", line 114, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\Users\amhma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\__main__.py", line 65, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\Users\amhma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\building\build_main.py", line 725, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "C:\Users\amhma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\building\build_main.py", line 672, in build
    exec(code, spec_namespace)
  File "C:\Users\amhma\Documents\Python\Personal Projects\Password Generator\main.spec", line 6, in <module>
    a = Analysis(['main.py'],
  File "C:\Users\amhma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\building\build_main.py", line 242, in __init__
    self.__postinit__()
  File "C:\Users\amhma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
    self.assemble()
  File "C:\Users\amhma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\building\build_main.py", line 391, in assemble
    self.binaries.extend(bindepend.Dependencies([('', python, '')],
  File "C:\Users\amhma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\depend\bindepend.py", line 224, in Dependencies
    for ftocnm, fn in getAssemblyFiles(pth, manifest, redirects):
  File "C:\Users\amhma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\depend\bindepend.py", line 403, in getAssemblyFiles
    for assembly in getAssemblies(pth):
  File "C:\Users\amhma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\depend\bindepend.py", line 354, in getAssemblies
    res = GetManifestResources(pth)
  File "C:\Users\amhma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\utils\win32\winmanifest.py", line 1016, in GetManifestResources
    return winresource.GetResources(filename, [RT_MANIFEST], names, languages)
  File "C:\Users\amhma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\utils\win32\winresource.py", line 170, in GetResources
    hsrc = win32api.LoadLibraryEx(filename, 0, LOAD_LIBRARY_AS_DATAFILE)
  File "C:\Users\amhma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
    return _dll._LoadLibraryEx(fileName, 0, flags)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\lib\contextlib.py", line 135, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Users\amhma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\win32ctypes\pywin32\pywintypes.py", line 37, in pywin32error
    raise error(exception.winerror, exception.function, exception.strerror)
win32ctypes.pywin32.pywintypes.error: (1920, 'LoadLibraryExW', 'The file cannot be accessed by the system.')

and actually, I don't know what is this error, it doesn't come for me ever!!

so please guys answer me quick

and sorry for making dramatic scenes

djvg
  • 11,722
  • 5
  • 72
  • 103
  • Does this answer your question? [Pyinstaller win32ctypes.pywin32.pywintypes.error: (1920, 'LoadLibraryExW', 'System cannot access the file')](https://stackoverflow.com/questions/57180580/pyinstaller-win32ctypes-pywin32-pywintypes-error-1920-loadlibraryexw-syst) – djvg Mar 18 '21 at 07:33
  • also similar: https://stackoverflow.com/q/58465209, https://stackoverflow.com/q/57932432 – djvg Mar 18 '21 at 07:36

1 Answers1

0

Looks like you are using Python from the Windows Store:

Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3...

From PyInstaller issue 4941:

We don't support using python from the windows store when not using a virtual environment. Please use a virtual environment; that should fix this.

So, try using a virtual environment.

djvg
  • 11,722
  • 5
  • 72
  • 103