运行pyinstaller时出错(1920,“ LoadLibraryEx”,“系统无法访问文件”)

时间:2019-10-19 15:33:10

标签: python python-3.x pyinstaller

我正在尝试将python脚本编译为exe,这样我就可以将其发送给可以与之一起使用的朋友,而不必安装python,但是我遇到了问题,无法找到解决方案。

我在Pyinstaller win32ctypes.pywin32.pywintypes.error: (1920, 'LoadLibraryExW', 'System cannot access the file')

发现了类似的问题

但是不能在那里发布,除非作为答案,我试图添加权限并取消隐藏“ WindowsApps”文件夹,但似乎无济于事。

这是运行pyinstaller时cmd给我的信息

瑞典语为“ Systemet kan inte kommaåtfilen”,因为“系统无法访问文件”

100 INFO: PyInstaller: 3.5
101 INFO: Python: 3.7.4
101 INFO: Platform: Windows-10-10.0.18362-SP0
103 INFO: wrote C:\Users\Jonathan\Pictures\shimbot2\gui.spec
106 INFO: UPX is not available.
109 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Jonathan\\Pictures', 'C:\\Users\\Jonathan\\Pictures\\shimbot2']
110 INFO: checking Analysis
110 INFO: Building Analysis because Analysis-00.toc is non existent
111 INFO: Initializing module dependency graph...
116 INFO: Initializing module graph hooks...
119 INFO: Analyzing base_library.zip ...
4140 INFO: running Analysis Analysis-00.toc
Traceback (most recent call last):
  File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\win32ctypes\pywin32\pywintypes.py", line 35, in pywin32error
    yield
  File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
    return _dll._LoadLibraryEx(fileName, 0, flags)
  File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\win32ctypes\core\cffi\_dll.py", line 26, in _LoadLibraryEx
    function_name='LoadLibraryEx')
  File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\win32ctypes\core\cffi\_util.py", line 81, in __call__
    self._raise_error(function_name)
  File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\win32ctypes\core\cffi\_util.py", line 92, in _raise_error
    raise exception
OSError: [WinError 1920] Systemet kan inte komma åt filen

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1264.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1264.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Jonathan\Pictures\shimbot2\pyinstaller.exe\__main__.py", line 7, in <module>
  File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\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:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\building\build_main.py", line 791, in build
    exec(code, spec_namespace)
  File "C:\Users\Jonathan\Pictures\shimbot2\gui.spec", line 17, in <module>
    noarchive=False)
  File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\building\build_main.py", line 243, in __init__
    self.__postinit__()
  File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
    self.assemble()
  File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\building\build_main.py", line 405, in assemble
    redirects=self.binding_redirects)[1:])
  File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\depend\bindepend.py", line 231, in Dependencies
    for ftocnm, fn in getAssemblyFiles(pth, manifest, redirects):
  File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\depend\bindepend.py", line 407, in getAssemblyFiles
    for assembly in getAssemblies(pth):
  File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\depend\bindepend.py", line 358, in getAssemblies
    res = GetManifestResources(pth)
  File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\utils\win32\winmanifest.py", line 1005, in GetManifestResources
    return winresource.GetResources(filename, [RT_MANIFEST], names, languages)
  File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\utils\win32\winresource.py", line 168, in GetResources
    hsrc = win32api.LoadLibraryEx(filename, 0, LOAD_LIBRARY_AS_DATAFILE)
  File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
    return _dll._LoadLibraryEx(fileName, 0, flags)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1264.0_x64__qbz5n2kfra8p0\lib\contextlib.py", line 130, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\win32ctypes\pywin32\pywintypes.py", line 37, in pywin32error
    raise error(exception.winerror, exception.function, exception.strerror)
win32ctypes.pywin32.pywintypes.error: (1920, 'LoadLibraryEx', 'Systemet kan inte komma åt filen')

3 个答案:

答案 0 :(得分:2)

由于PyInstaller无法访问构建应用程序所需的DLL,因此我们不支持Windows应用商店版本的python。请使用某种虚拟环境或从https://python.org

安装python

答案 1 :(得分:0)

我对此有相同的问题,显然这与共享文件系统有关。

您提供的帖子中的解决方案帮助我对问题进行了排序,请通过以下链接指导您创建虚拟环境:

https://www.google.com/amp/s/www.geeksforgeeks.org/python-virtual-environment/amp/

如果您对pyinstaller没有“被识别为内部或外部命令”有任何疑问,请不要忘记将虚拟环境pyinstaller模块添加到环境变量中。

答案 2 :(得分:0)

我在Pyinstaller中遇到了完全相同的'(1920,'LoadLibraryEx','系统无法访问该文件')'问题,在对该问题进行了许多思考之后决定清理​​我的Python环境。因此,我卸载了Python 3.6和3.7,然后卸载了PyCharm和Anaconda。

然后安装了Python 3.8和Pip 3.8,然后安装了Pyinstaller和它!我的预感是问题是3.6和3.7之间的冲突,但这只是预感。我确实认为PyCharm和Anaconda是很棒的产品--从现在开始,我将更加谨慎地对待我的Python环境。

[BTW Pyinstaller第一次在我的Linux开发箱上完美运行。]