创建python脚本[WinError 6]的.exe文件时出错句柄无效

2024-05-15 13:45:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我安装了Python3.8并尝试使用它

pyinstaller --onefile -w audio_converter.py

为了在windows和linux中创建可执行文件,我在linux中成功创建了一个,但在windows中尝试时收到警告

正如建议的那样here,我降级到了Python3.7,但我仍然得到相同的错误

python脚本本身没有错误,它可以完美地运行,下面是windows中cmd的输出

G:\Projects\audio_converter>pyinstaller --onefile -w audio_converter.py
283 INFO: PyInstaller: 3.6
283 INFO: Python: 3.7.8
283 INFO: Platform: Windows-10-10.0.18362-SP0
283 INFO: wrote G:\Projects\audio_converter\audio_converter.spec
283 INFO: UPX is not available.
283 INFO: Extending PYTHONPATH with paths
['G:\\Projects\\audio_converter', 'G:\\Projects\\audio_converter']
283 INFO: checking Analysis
283 INFO: Building Analysis because Analysis-00.toc is non existent
283 INFO: Initializing module dependency graph...
299 INFO: Caching module graph hooks...
299 INFO: Analyzing base_library.zip ...
2882 INFO: Processing pre-find module path hook   distutils
2882 INFO: distutils: retargeting to non-venv dir 'c:\\program files\\python37\\lib'
4647 INFO: Caching module dependency graph...
4803 INFO: running Analysis Analysis-00.toc
4819 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\program files\python37\python.exe
4913 INFO: Analyzing G:\Projects\audio_converter\audio_converter.py
5335 INFO: Processing module hooks...
5335 INFO: Loading module hook "hook-distutils.py"...
5335 INFO: Loading module hook "hook-encodings.py"...
5444 INFO: Loading module hook "hook-pydoc.py"...
5444 INFO: Loading module hook "hook-sysconfig.py"...
5444 INFO: Loading module hook "hook-xml.py"...
5756 INFO: Loading module hook "hook-_tkinter.py"...
5944 INFO: checking Tree
5944 INFO: Building Tree because Tree-00.toc is non existent
5944 INFO: Building Tree Tree-00.toc
6006 INFO: checking Tree
6006 INFO: Building Tree because Tree-01.toc is non existent
6006 INFO: Building Tree Tree-01.toc
6053 INFO: Looking for ctypes DLLs
6053 INFO: Analyzing run-time hooks ...
6053 INFO: Including run-time hook 'pyi_rth__tkinter.py'
6069 INFO: Looking for dynamic libraries
6381 INFO: Looking for eggs
6389 INFO: Using Python library c:\program files\python37\python37.dll
6389 INFO: Found binding redirects:
[]
6389 INFO: Warnings written to G:\Projects\audio_converter\build\audio_converter\warn-audio_converter.txt
6436 INFO: Graph cross-reference written to G:\Projects\audio_converter\build\audio_converter\xref-audio_converter.html
6514 INFO: checking PYZ
6514 INFO: Building PYZ because PYZ-00.toc is non existent
6514 INFO: Building PYZ (ZlibArchive) G:\Projects\audio_converter\build\audio_converter\PYZ-00.pyz
7166 INFO: Building PYZ (ZlibArchive) G:\Projects\audio_converter\build\audio_converter\PYZ-00.pyz completed successfully.
7213 INFO: checking PKG
7213 INFO: Building PKG because PKG-00.toc is non existent
7228 INFO: Building PKG (CArchive) PKG-00.pkg
13916 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
13994 INFO: Bootloader C:\Users\ebene\AppData\Roaming\Python\Python37\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
13994 INFO: checking EXE
13994 INFO: Building EXE because EXE-00.toc is non existent
13994 INFO: Building EXE from EXE-00.toc
14010 INFO: Appending archive to EXE G:\Projects\audio_converter\dist\audio_converter.exe
14525 INFO: Building EXE from EXE-00.toc completed successfully.

以及警告文件的内容

This file lists modules PyInstaller was not able to find. This does not
necessarily mean this module is required for running you program. Python and
Python 3rd-party packages include a lot of conditional or optional modules. For
example the module 'ntpath' only exists on Windows, whereas the module
'posixpath' only exists on Posix systems.

Types if import:
* top-level: imported at the top-level - look at these first
* conditional: imported within an if-statement
* delayed: imported from within a function
* optional: imported within a try-except-statement

IMPORTANT: Do NOT post this list to the issue-tracker. Use it as a basis for
           yourself tracking down the missing module. Thanks!

missing module named _posixsubprocess - imported by subprocess (conditional)
missing module named 'org.python' - imported by copy (optional), xml.sax (delayed, conditional)
missing module named pwd - imported by posixpath (delayed, conditional), shutil (optional), tarfile (optional), http.server (delayed, optional), webbrowser (delayed), netrc (delayed, conditional), getpass (delayed)
missing module named posix - imported by os (conditional, optional)
missing module named resource - imported by posix (top-level)
missing module named org - imported by pickle (optional)
missing module named grp - imported by shutil (optional), tarfile (optional)
missing module named termios - imported by tty (top-level), getpass (optional)
missing module named vms_lib - imported by platform (delayed, conditional, optional)
missing module named 'java.lang' - imported by platform (delayed, optional), xml.sax._exceptions (conditional)
missing module named java - imported by platform (delayed)
missing module named _scproxy - imported by urllib.request (conditional)
missing module named _winreg - imported by platform (delayed, optional)
missing module named _frozen_importlib_external - imported by importlib._bootstrap (delayed), importlib (optional), importlib.abc (optional)
excluded module named _frozen_importlib - imported by importlib (optional), importlib.abc (optional)
missing module named readline - imported by cmd (delayed, conditional, optional), code (delayed, conditional, optional), pdb (delayed, optional)
missing module named StringIO - imported by pydub.audio_segment (optional)
missing module named pyaudioop - imported by pydub.utils (optional)

当我运行exe文件时,gui工作正常,但当我运行函数时,会出现以下错误:

[WinError 6] : The handle is invalid

Tags: pyinfobyhookaudiooptionalconverternamed