ALRebo 2023-01-23 14:13 采纳率: 75%
浏览 96
已结题

关于pyinstaller打包问题

执行代码正常,但
使用pyinstaller打包工具打包下列代码报错

img


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', '系统找不到指定的文件。')

展开全部

  • 写回答

1条回答 默认 最新

  • Mike Qin 2023-01-23 16:59
    关注

    新年快乐🎉,望采纳,谢谢!
    这个问题可能是由于pyinstaller打包时遇到了Python代码中的一些语法错误或缺少的模块导致的。可以尝试检查Python代码是否有语法错误,或者查看是否缺少了某些模块。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
    ALRebo 2023-01-24 02:11

    谢谢,我又重装了python和重新配置了变量,模块问题已解决
    新年快乐🎉

    回复
编辑
预览

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 1月24日
  • 已采纳回答 1月24日
  • 创建了问题 1月23日

悬赏问题

  • ¥15 代写uni代码,app唤醒
  • ¥15 全志t113i启动qt应用程序提示internal error
  • ¥15 ensp可以看看嘛.
  • ¥80 51单片机C语言代码解决单片机为AT89C52是清翔单片机
  • ¥60 优博讯DT50高通安卓11系统刷完机自动进去fastboot模式
  • ¥15 minist数字识别
  • ¥15 在安装gym库的pygame时遇到问题,不知道如何解决
  • ¥20 uniapp中的webview 使用的是本地的vue页面,在模拟器上显示无法打开
  • ¥15 网上下载的3DMAX模型,不显示贴图怎么办
  • ¥15 关于#stm32#的问题:寻找一块开发版,作为智能化割草机的控制模块和树莓派主板相连,要求:最低可控制 3 个电机(两个驱动电机,1 个割草电机),其次可以与树莓派主板相连电机照片如下:
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部