PyInstaller работает для Linux на Windows, но я не могу заставить его работать с Windows для создания .exe - PullRequest
1 голос
/ 29 апреля 2020

Я пытаюсь выяснить, как сделать исполняемый файл для моих сценариев, чтобы люди в офисе могли использовать их для своих нужд (в большинстве не будет установлено python).

Я работаю Windows 10.

Мне удалось заставить pyinstaller работать на Ubuntu на windows, но я не могу получить это с помощью windows напрямую.

Есть ли метод преобразования linux исполняемого файла в windows или кто-нибудь знает, что происходит? Я скопировал полный отчет об ошибке ниже windows.

C:\Users\Jesse\Desktop\DrawingFiles\Python>python3 pyinstaller --onefile hello.py
71 INFO: PyInstaller: 3.6
71 INFO: Python: 3.8.2
71 INFO: Platform: Windows-10-10.0.18362-SP0
72 INFO: wrote C:\Users\Jesse\Desktop\DrawingFiles\Python\hello.spec
74 INFO: UPX is not available.
75 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Jesse\\Desktop\\DrawingFiles\\Python',
 'C:\\Users\\Jesse\\Desktop\\DrawingFiles\\Python']
75 INFO: checking Analysis
76 INFO: Building Analysis because Analysis-00.toc is non existent
76 INFO: Initializing module dependency graph...
78 INFO: Caching module graph hooks...
85 INFO: Analyzing base_library.zip ...
2486 INFO: Processing pre-find module path hook   distutils
2487 INFO: distutils: retargeting to non-venv dir 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.8_3.8.752.0_x64__qbz5n2kfra8p0\\lib'
3950 INFO: Caching module dependency graph...
4058 INFO: running Analysis Analysis-00.toc
Traceback (most recent call last):
  File "C:\Users\Jesse\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\Jesse\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\Jesse\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\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 "pyinstaller", line 11, in <module>
    sys.exit(run())
  File "C:\Users\Jesse\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\Jesse\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\Jesse\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\Jesse\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\Jesse\Desktop\DrawingFiles\Python\hello.spec", line 6, in <module>
    a = Analysis(['hello.py'],
  File "C:\Users\Jesse\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\Jesse\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\Jesse\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\Jesse\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\Jesse\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\Jesse\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\Jesse\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\Jesse\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\Jesse\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\Jesse\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, 'LoadLibraryExW', 'The file cannot be accessed by the system.')

Спасибо,

JT

1 Ответ

0 голосов
/ 29 апреля 2020

Проблема с Pyinstaller. У меня была эта проблема раньше. Если вы хотите создать exe-файл с использованием Pyinstaller, то вам нужно сделать это с ОС, с которой вы хотите, чтобы он был совместим. Это означает, что вы используете Pyinstaller для windows, и файл будет работать для windows.

...