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

从本地目录安装Python包时出现setuptools-scm版本检测错误

解决setuptools-scm无法检测版本的问题

核心错误信息

LookupError: setuptools-scm was unable to detect version for '/home/michael/Downloads/inversion/s2shores'.

Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.

解决思路

  • 获取完整Git仓库:让同事提供包含.git文件夹的完整项目目录,或者直接给出Git仓库地址,用git clone命令拉取代码。setuptools-scm依赖Git仓库的提交记录、标签生成版本号,缺失.git文件夹会导致无法检测版本。
  • 手动指定版本号(临时方案):修改项目根目录的setup.py文件,在setup()函数中手动添加version参数:
    setup(use_pyscaffold=True, version="0.1.0")  # 替换为项目实际版本号
    
    修改后重新执行pip install -e s2shores即可完成安装。
  • 使用预打包的PyPI格式文件:询问同事是否有生成好的.tar.gz或.whl格式包,这类包在打包时已包含版本元数据,无需依赖Git仓库就能正常安装。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.19 10:05:13