执行代码正常,但
使用pyinstaller打包工具打包下列代码报错
C:https://img-mid.csdnimg.cn/release/static/image/mid/ask/759388284476128.png "#left")
\Users\Administrator>pyinstaller -F C:\Users\Administrator\Desktop\icotools.py
500 INFO: PyInstaller: 5.6.2
500 INFO: Python: 3.11.0
510 INFO: Platform: Windows-10-10.0.19045-SP0
510 INFO: wrote C:\Users\Administrator\icotools.spec
520 INFO: UPX is not available.
520 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Administrator\\Desktop']
1230 INFO: checking Analysis
1230 INFO: Building Analysis because Analysis-00.toc is nonhttps://img-mid.csdnimg.cn/release/static/image/mid/ask/181578284476138.png "#left")
existent
1230 INFO: Initializing module dependency graph...
1240 INFO: Caching module graph hooks...
1250 WARNING: Several hooks defined for module 'numpy'. Please take care they do not conflict.
1260 INFO: Analyzing base_library.zip ...
3575 INFO: Loading module hook 'hook-encodings.py' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks'...
4465 INFO: Loading module hook 'hook-heapq.py' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks'...
6045 INFO: Loading module hook 'hook-pickle.py' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks'...
8079 INFO: Caching module dependency graph...
8219 INFO: running Analysis Analysis-00.toc
8229 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by C:\Users\Administrator\AppData\Local\Programs\Python\Python311\python.exe
8429 INFO: Analyzing C:\Users\Administrator\Desktop\icotools.py
8449 INFO: Loading module hook 'hook-PIL.py' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks'...
8539 INFO: Loading module hook 'hook-PIL.Image.py' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks'...
9459 INFO: Loading module hook 'hook-numpy.py' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\numpy\\_pyinstaller'...
10069 INFO: Loading module hook 'hook-numpy._pytesttester.py' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks'...
10479 INFO: Loading module hook 'hook-difflib.py' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks'...
10769 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks'...
10989 INFO: Loading module hook 'hook-xml.py' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks'...
11809 INFO: Loading module hook 'hook-platform.py' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks'...
12159 INFO: Loading module hook 'hook-sysconfig.py' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks'...
12832 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks'...
14042 INFO: Loading module hook 'hook-packaging.py' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks'...
14102 INFO: Loading module hook 'hook-PIL.ImageFilter.py' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks'...
14122 INFO: Processing module hooks...
14262 INFO: Loading module hook 'hook-pkg_resources.py' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks'...
15972 INFO: Loading module hook 'hook-PIL.SpiderImagePlugin.py' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks'...
16052 INFO: Processing pre-safe import module hook win32com from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\pre_safe_import_module\\hook-win32com.py'.
16153 INFO: Loading module hook 'hook-win32com.py' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
16153 INFO: Loading module hook 'hook-pythoncom.py' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\__init__.py", line 45, in <module>
import pkg_resources
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\pkg_resources\__init__.py", line 23, in <module>
import zipfile
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\zipfile.py", line 19, in <module>
import pathlib
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\pathlib.py", line 10, in <module>
from collections import Sequence
ImportError: cannot import name 'Sequence' from 'collections' (C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\collections\__init__.py)
64190 INFO: Loading module hook 'hook-pywintypes.py' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\__init__.py", line 45, in <module>
import pkg_resources
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\pkg_resources\__init__.py", line 23, in <module>
import zipfile
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\zipfile.py", line 19, in <module>
import pathlib
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\pathlib.py", line 10, in <module>
from collections import Sequence
ImportError: cannot import name 'Sequence' from 'collections' (C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\collections\__init__.py)
94824 INFO: Looking for ctypes DLLs
94934 INFO: Analyzing run-time hooks ...
94944 INFO: Including run-time hook 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
94944 INFO: Including run-time hook 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_subprocess.py'
94944 INFO: Including run-time hook 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgres.py'
94954 INFO: Including run-time hook 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_win32comgenpy.py'
94954 INFO: Including run-time hook 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\rthooks\\pyi_rth_pywintypes.py'
94954 INFO: Including run-time hook 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\rthooks\\pyi_rth_pythoncom.py'
94964 INFO: Including run-time hook 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'
94964 INFO: Including run-time hook 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
94984 INFO: Looking for dynamic libraries
C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\building\build_main.py:173: UserWarning: The numpy.array_api submodule is still experimental. See NEP 47.
__import__(package)
539 INFO: Extra DLL search directories (AddDllDirectory): ['C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\numpy\\.libs']
539 INFO: Extra DLL search directories (PATH): ['C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath', 'C:\\Windows\\system32', 'C:\\Windows', 'C:\\Windows\\System32\\Wbem', 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\', 'C:\\Windows\\System32\\OpenSSH\\', 'C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\110\\Tools\\Binn\\', 'C:\\Program Files (x86)\\Microsoft SQL Server\\120\\Tools\\Binn\\', 'C:\\Program Files\\Microsoft SQL Server\\120\\Tools\\Binn\\', 'C:\\Program Files\\Microsoft SQL Server\\120\\DTS\\Binn\\', 'C:\\Program Files (x86)\\Windows Kits\\8.1\\Windows Performance Toolkit\\', 'C:\\WINDOWS\\system32', 'C:\\WINDOWS', 'C:\\WINDOWS\\System32\\Wbem', 'C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\', 'C:\\WINDOWS\\System32\\OpenSSH\\', 'C:\\Program Files\\Bandizip\\', 'C:\\Users\\Administrator\\PycharmProjects\\pythonProject\\venv\\Scripts\\python.exe', 'C:\\Program Files\\ffmpeg-master-latest-win64-gpl-shared\\bin', 'C:\\Users\\Administrator\\env\\Scripts\\pip.exe', 'C:\\Program Files\\dotnet\\', 'C:\\Program Files (x86)\\dotnet\\', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\Scripts\\', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\', 'G:\\qq游戏\\QQGameTempest\\Hall.57915\\', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Microsoft VS Code\\bin', 'C:\\Users\\Administrator\\PycharmProjects\\pythonProject\\venv\\Scripts']
20195 INFO: Cannot get manifest resource from non-PE file PycharmProjects\pythonProject\venv\Lib\site-packages\PyQt5\Qt5\translations\qtquickcontrols2_da.qm
20195 WARNING: Cannot get binary dependencies for file: PycharmProjects\pythonProject\venv\Lib\site-packages\PyQt5\Qt5\translations\qtquickcontrols2_da.qm
20195 WARNING: Reason: 'DOS Header magic not found.'
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\__main__.py", line 179, in run
run_build(pyi_config, spec_file, **vars(args))
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\__main__.py", line 60, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\building\build_main.py", line 963, in main
build(specfile, distpath, workpath, clean_build)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\building\build_main.py", line 885, in build
exec(code, spec_namespace)
File "C:\Users\Administrator\icotools.spec", line 7, in <module>
a = Analysis(
^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\building\build_main.py", line 410, in __init__
self.__postinit__()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\building\datastruct.py", line 173, in __postinit__
self.assemble()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\building\build_main.py", line 689, in assemble
isolated.call(find_binary_dependencies, list(self.binaries), self.binding_redirects, collected_packages)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\isolated\_parent.py", line 337, in call
return isolated.call(function, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\isolated\_parent.py", line 275, in call
raise RuntimeError(f"Child process call to {function.__name__}() failed with:\n" + output)
RuntimeError: Child process call to find_binary_dependencies() failed with:
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 35, in pywin32error
yield
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
return _dll._LoadLibraryEx(fileName, 0, flags)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\win32ctypes\core\ctypes\_util.py", line 42, in check_null
raise make_error(function, function_name)
OSError: [WinError 2] 系统找不到指定的文件。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\isolated\_child.py", line 63, in run_next_command
output = function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\building\build_main.py", line 191, in find_binary_dependencies
return bindepend.Dependencies(binaries, redirects=binding_redirects, xtrapath=extra_libdirs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\depend\bindepend.py", line 287, in Dependencies
for ftocnm, fn in getAssemblyFiles(pth, manifest, redirects):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\depend\bindepend.py", line 461, in getAssemblyFiles
for assembly in getAssemblies(pth):
^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\depend\bindepend.py", line 415, in getAssemblies
res = winmanifest.GetManifestResources(pth)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\utils\win32\winmanifest.py", line 979, in GetManifestResources
return winresource.GetResources(filename, [RT_MANIFEST], names, languages)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\utils\win32\winresource.py", line 155, in GetResources
hsrc = win32api.LoadLibraryEx(filename, 0, LOAD_LIBRARY_AS_DATAFILE)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\win32ctypes\pywin32\win32api.py", line 42, in LoadLibraryEx
with _pywin32error():
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 155, in __exit__
self.gen.throw(typ, value, traceback)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 37, in pywin32error
raise error(exception.winerror, exception.function, exception.strerror)
win32ctypes.pywin32.pywintypes.error: (2, 'LoadLibraryExW', '系统找不到指定的文件。')