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

安装tf-models-official时出现metadata-generation-failed错误求助

解决安装tf-models-official时kaggle依赖的构建错误

尝试执行!pip install tf-models-official安装TensorFlow官方模型库时,在收集依赖kaggle>=1.3.9阶段触发元数据生成失败,错误日志如下:

Collecting kaggle>=1.3.9 (from tf-models-official)
  Using cached kaggle-1.6.15.tar.gz (9.1 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [35 lines of output]
      Traceback (most recent call last):
        File "/home/ec2-user/anaconda3/envs/tensorflow2_p310/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/ec2-user/anaconda3/envs/tensorflow2_p310/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/ec2-user/anaconda3/envs/tensorflow2_p310/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 152, in prepare_metadata_for_build_wheel
          whl_basename = backend.build_wheel(metadata_directory, config_settings)
        File "/tmp/pip-build-env-fqrzl9xw/overlay/lib/python3.10/site-packages/hatchling/build.py", line 58, in build_wheel
          return os.path.basename(next(builder.build(directory=wheel_directory, versions=['standard'])))
        File "/tmp/pip-build-env-fqrzl9xw/overlay/lib/python3.10/site-packages/hatchling/builders/plugin/interface.py", line 155, in build
          artifact = version_api[version](directory, **build_data)
        File "/tmp/pip-build-env-fqrzl9xw/overlay/lib/python3.10/site-packages/hatchling/builders/wheel.py", line 475, in build_standard
          for included_file in self.recurse_included_files():
        File "/tmp/pip-build-env-fqrzl9xw/overlay/lib/python3.10/site-packages/hatchling/builders/plugin/interface.py", line 176, in recurse_included_files
          yield from self.recurse_selected_project_files()
        File "/tmp/pip-build-env-fqrzl9xw/overlay/lib/python3.10/site-packages/hatchling/builders/plugin/interface.py", line 180, in recurse_selected_project_files
          if self.config.only_include:
        File "/tmp/pip-build-env-fqrzl9xw/overlay/lib/python3.10/site-packages/hatchling/builders/config.py", line 806, in only_include
          only_include = only_include_config.get('only-include', self.default_only_include()) or self.packages
        File "/tmp/pip-build-env-fqrzl9xw/overlay/lib/python3.10/site-packages/hatchling/builders/wheel.py", line 260, in default_only_include
          return self.default_file_selection_options.only_include
        File "/home/ec2-user/anaconda3/envs/tensorflow2_p310/lib/python3.10/functools.py", line 981, in __get__
          val = self.func(instance)
        File "/tmp/pip-build-env-fqrzl9xw/overlay/lib/python3.10/site-packages/hatchling/builders/wheel.py", line 248, in default_file_selection_options
          raise ValueError(message)
      ValueError: Unable to determine which files to ship inside the wheel using the following heuristics: https://hatch.pypa.io/latest/plugins/builder/wheel/#default-file-selection
      
      The most likely cause of this is that there is no directory that matches the name of your project (kaggle).
      
      At least one file selection option must be defined in the `tool.hatch.build.targets.wheel` table, see: https://hatch.pypa.io/latest/config/build/
      
      As an example, if you intend to ship a directory named `foo` that resides within a `src` directory located at the root of your project, you can define the following:
      
      [tool.hatch.build.targets.wheel]
      packages = ["src/foo"]
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

解决方法

  • 先安装kaggle的稳定版本(避开有构建问题的1.6.15版):
    pip install kaggle==1.6.14
    
  • 再执行tf-models-official的安装:
    pip install tf-models-official
    
  • 也可以一步完成,强制指定兼容的kaggle版本:
    pip install tf-models-official kaggle==1.6.14
    

问题原因

kaggle 1.6.15版本的构建配置存在缺陷,导致pip无法正确生成wheel包的元数据,回退到上一个稳定版本即可解决该问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.20 17:19:59