You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PyInstaller打包Windows服务时遇'urllib3.packages.six.moves'模块缺失错误

PyInstaller打包Windows服务出现ModuleNotFoundError: No module named 'urllib3.packages.six.moves'
  • 用PyInstaller将脚本打包为Windows服务,运行时触发上述错误
  • 虚拟环境中执行的打包命令:pyinstaller.exe --onefile --runtime-tmpdir=. --hidden-import win32timezone --hidden-import urllib3 laps_service.py,已添加urllib3作为隐式导入但无效
  • 已尝试卸载重装urllib3和requests:因servicemanager依赖要求安装了requests==2.24.0,pip自动替换为兼容的urllib3-1.25.11,且已安装six,但问题未解决
  • 此前该脚本在虚拟环境中打包为普通exe可正常运行,推测是包版本问题,但pip check未检测到依赖损坏
  • 手头有旧版可正常运行的exe,若能查看其中的包版本或许有助于定位问题

完整报错栈:

PS C:\LAPS> .\laps_service.exe --startup delayed install
Traceback (most recent call last):
  File "laps_service.py", line 29, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
  File "requests\__init__.py", line 43, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
  File "urllib3\__init__.py", line 7, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
  File "urllib3\connectionpool.py", line 11, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
  File "urllib3\exceptions.py", line 2, in <module>
ModuleNotFoundError: No module named 'urllib3.packages.six.moves'
[14276] Failed to execute script 'laps_service' due to unhandled exception!

内容的提问来源于stack exchange,提问作者Mike Saunders

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 14:47:04