Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyinstaller error: "The file cannot be accessed by the system" #1

Open
wiseman opened this issue Mar 12, 2021 · 1 comment
Open

pyinstaller error: "The file cannot be accessed by the system" #1

wiseman opened this issue Mar 12, 2021 · 1 comment

Comments

@wiseman
Copy link

wiseman commented Mar 12, 2021

Thanks for this! I was hoping something like this existed, and I googled and was taken directly here; perfect. The release exe works fine for me, but I wanted to add automatic conversion to JPG (Google Maps doesn't seem to be able to handle geotagged PNGs). Unfortunately, when I try to build the exe, I get an error. It's not clear to me what file it's having an issue with.

PS C:\Users\jjwis\Documents\src\msfs-screenshot-gps-data> python -m PyInstaller --add-data="SimConnect/SimConnect.dll;SimConnect/" --clean --exclude-module=.git --name="msfs-screenshot-gps-data" --onefile app.py
57 INFO: PyInstaller: 4.2
57 INFO: Python: 3.9.2
58 INFO: Platform: Windows-10-10.0.19041-SP0
60 INFO: wrote C:\Users\jjwis\Documents\src\msfs-screenshot-gps-data\msfs-screenshot-gps-data.spec
63 INFO: UPX is not available.
63 INFO: Removing temporary files and cleaning cache in C:\Users\jjwis\AppData\Roaming\pyinstaller
65 INFO: Extending PYTHONPATH with paths
['C:\\Users\\jjwis\\Documents\\src\\msfs-screenshot-gps-data',
 'C:\\Users\\jjwis\\Documents\\src\\msfs-screenshot-gps-data']
74 INFO: checking Analysis
74 INFO: Building Analysis because Analysis-00.toc is non existent
74 INFO: Initializing module dependency graph...
78 INFO: Caching module graph hooks...
86 WARNING: Several hooks defined for module 'win32ctypes.core'. Please take care they do not conflict.
91 INFO: Analyzing base_library.zip ...
1795 INFO: Processing pre-find module path hook distutils from 'C:\\Users\\jjwis\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python39\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
1796 INFO: distutils: retargeting to non-venv dir 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\\lib'
3219 INFO: Caching module dependency graph...
3308 INFO: running Analysis Analysis-00.toc
Traceback (most recent call last):
  File "C:\Users\jjwis\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\win32ctypes\pywin32\pywintypes.py", line 35, in pywin32error
    yield
  File "C:\Users\jjwis\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:\Users\jjwis\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\win32ctypes\core\ctypes\_util.py", line 42, in check_null
    raise make_error(function, function_name)
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.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\jjwis\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\__main__.py", line 124, in <module>
    run()
  File "C:\Users\jjwis\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\jjwis\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\jjwis\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\jjwis\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\jjwis\Documents\src\msfs-screenshot-gps-data\msfs-screenshot-gps-data.spec", line 6, in <module>
    a = Analysis(['app.py'],
  File "C:\Users\jjwis\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\jjwis\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\jjwis\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\jjwis\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\jjwis\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\jjwis\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\jjwis\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\jjwis\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\jjwis\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\jjwis\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.')
@Luuk3333
Copy link
Owner

Luuk3333 commented Mar 16, 2021

Hi,

Unfortunately I was unable to replicate your issue.
I was going to suggest to try using a virtual environment which I should have been using anyways. However, that results in Microsoft Defender Antivirus marking the built .exe files as false-positives (related to pyinstaller).

To avoid more problems like these in the future and since this is all on Windows I think the best solution would be to rewrite this app in something more Microsoft-y like C#.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants