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

setuptools配置过时报错及tf-models-official依赖问题求助

问题:安装TensorFlow Object Detection依赖时触发setuptools弃用警告导致构建失败

问题场景

跟随视频开发项目,执行对应命令时出现构建错误。

报错信息

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [68 lines of output]
C:\Users\pc\AppData\Local\Temp\pip-build-env-_03xpo02\overlay\Lib\site-packages\setuptools\config\setupcfg.py:293: _DeprecatedConfig: Deprecated config in setup.cfg
!!

********************************************************************************
        The license_file parameter is deprecated, use license_files instead.

        By 2023-Oct-30, you need to update your project and remove deprecated calls
        or your builds will no longer be supported.

        ********************************************************************************

!!

已尝试操作

  • 执行 pip install setuptools==58.2.0 降级setuptools版本
  • 执行 pip install . 本地安装项目

环境信息

  • Python版本:3.11.4

项目setup.py代码

import os
from setuptools import find_packages
from setuptools import setup

REQUIRED_PACKAGES = [
    'avro-python3', 'apache-beam','pillow','lxml','matplotlib','Cython',
    'contextlib2','tf-slim','six','pycocotools','lvis','scipy','pandas',
    'tf-models-official>=2.5.1','tensorflow_io','keras',
    'pyparsing==2.4.7',  # TODO(b/204103388)
    'sacrebleu<=2.2.0'  # https://github.com/mjpost/sacrebleu/issues/209
]

setup(
    name='object_detection',
    version='0.1',
    install_requires=REQUIRED_PACKAGES,
    include_package_data=True,
    packages=(
        [p for p in find_packages() if p.startswith('object_detection')] +
        find_packages(where=os.path.join('.', 'slim'))),
    package_dir={
        'datasets': os.path.join('slim', 'datasets'),
        'nets': os.path.join('slim', 'nets'),
        'preprocessing': os.path.join('slim', 'preprocessing'),
        'deployment': os.path.join('slim', 'deployment'),
        'scripts': os.path.join('slim', 'scripts'),
    },
    description='Tensorflow Object Detection Library',
    python_requires='>3.6',
)

排查结果

问题根源是依赖项 tf-models-official>=2.5.1 使用了setuptools已弃用的license_file配置参数。

解决方案

1. 锁定兼容版本的tf-models-official

将REQUIRED_PACKAGES中的tf-models-official>=2.5.1修改为tf-models-official==2.13.0(该版本已修复license_file弃用问题,同时适配Python3.11),然后重新执行安装:

pip install .

2. 临时屏蔽弃用警告(不推荐长期使用)

若必须使用旧版本依赖,可通过环境变量屏蔽警告,执行安装命令:

SETUPTOOLS_DEPRECATION_WARNINGS=0 pip install .

注意:此方法仅隐藏警告,未解决根本问题,后续版本可能直接构建失败。

3. 手动修复依赖包配置(进阶操作)

下载tf-models-official>=2.5.1的源码,找到其setup.cfg文件,将license_file替换为license_files = LICENSE,然后本地安装修改后的包。

内容的提问来源于stack exchange,提问作者Emir Ünalan

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 02:43:34