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

安装lap包失败求助:YOLOv8跟踪功能无法运行

安装lap包失败导致YOLOv8跟踪功能无法使用的解决建议

问题背景

执行pip install lap时安装失败,lap是YOLOv8跟踪功能的必需依赖,使用代码如下:

from ultralytics import YOLO
model = YOLO('best.pt')
results = model.track(source="1.mp4", conf=0.3) 

报错信息

pip install lap
WARNING: Ignoring invalid distribution -pencv-python (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -rotobuf (c:\python310\lib\site-packages)
Collecting lap
  Using cached lap-0.4.0.tar.gz (1.5 MB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: lap
  Building wheel for lap (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [50 lines of output]
      Partial import of lap during the build process.
      C:\Users\AppData\Local\Temp\pip-install-5n1k5a80\lap_5ee53496753c49158b96af0ae0829a26\setup.py:223: DeprecationWarning:        

        `numpy.distutils` is deprecated since NumPy 1.23.0, as a result
        of the deprecation of `distutils` itself. It will be removed for
        Python >= 3.12. For older Python versions it will remain present.
        It is recommended to use `setuptools < 60.0` for those Python versions.
        For more details, see:
          https://numpy.org/devdocs/reference/distutils_status_migration.html


        from numpy.distutils.core import setup
      Generating cython files
      running bdist_wheel
      running build
      running config_cc
      INFO: unifing config_cc, config, build_clib, build_ext, build commands --compiler options
      running config_fc
      INFO: unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
      running build_src
      INFO: build_src
      INFO: building extension "lap._lapjv" sources
      INFO: building data_files sources
      INFO: build_src: building npy-pkg config files
      C:\Python310\lib\site-packages\setuptools\_distutils\cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
      !!

              ********************************************************************************
              Please avoid running ``setup.py`` directly.
              Instead, use pypa/build, pypa/installer, pypa/build or
              other standards-based tools.

              See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
              ********************************************************************************

      !!
        self.initialize_options()
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-310
      creating build\lib.win-amd64-cpython-310\lap
      copying lap\lapmod.py -> build\lib.win-amd64-cpython-310\lap
      copying lap\__init__.py -> build\lib.win-amd64-cpython-310\lap
      running build_ext
      INFO: No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
      INFO: customize MSVCCompiler
      INFO: customize MSVCCompiler using build_ext
      INFO: CCompilerOpt.cc_test_flags[1077] : testing flags (/O2)
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      INFO: CCompilerOpt.cache_flush[857] : write cache to path -> C:\Users\AppData\Local\Temp\pip-install-5n1k5a80\lap_5ee53496753c49158b96af0ae0829a26\build\temp.win-amd64-cpython-310\Release\ccompiler_opt_cache_ext.py
      [end of output]



  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for lap
  Running setup.py clean for lap
Failed to build lap
ERROR: Could not build wheels for lap, which is required to install pyproject.toml-based projects

已尝试操作

  • 升级setuptools至最新版本
  • 安装CMake

解决步骤

1. 修复损坏的Python包

报错开头的无效包警告会干扰安装流程,先强制重装修复:

pip install --force-reinstall opencv-python protobuf

2. 安装MSVC编译器

报错核心提示缺少Microsoft Visual C++ 14.0及以上版本,这是编译lap包的必要条件:

  • 安装Microsoft C++ Build Tools,必须勾选**"Desktop development with C++"**组件,包含编译器、Windows SDK等工具。
  • 安装完成后重启电脑,确保环境变量生效。

3. 适配setuptools版本

根据numpy.distutils的弃用提示,降级setuptools到指定版本:

pip install setuptools==59.8.0

4. 重新安装lap

完成以上步骤后,重新执行安装命令:

pip install lap

备选方案:使用预编译wheel包

如果编译仍失败,可直接安装预编译的wheel文件:

  • 找到对应Python3.10+Windows64位的lap wheel包,下载后执行:
pip install [下载的wheel文件名].whl

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.20 20:35:16