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

如何用Bandersnatch构建指定Python版本离线PyPI源并解决包缺失问题

配置问题分析与解决方案

一、当前配置的错误点

你在[allowlist]中设置platforms = py3.6.8、py3.8.6、py3.8.7、py3.10.6是完全错误的:

  • Bandersnatch的platforms字段属于[filter]配置块,而非[allowlist];
  • platforms的有效值是平台架构标签(如manylinux_2_17_x86_64、win_amd64、any),不是具体的Python版本号;
  • 错误的配置导致过滤逻辑异常,直接排除了requests这类通用包(其wheel包标签为py3-none-any.whl,平台标签是any,无法匹配你设置的无效值)。

二、修正后的配置方案

编辑/etc/bandersnatch.conf,按以下规则调整:

  1. 移除错误的[allowlist]中platforms相关配置(如果不需要仅同步特定包,可直接删除整个[allowlist]块);
  2. 添加[filter]块,配置符合需求的过滤规则:
[filter]
# 仅保留源码包(tar.gz)和wheel包
formats = sdist, bdist_wheel
# 允许适配Python 3.6.x、3.8.x、3.10.x的包(自动覆盖你指定的小版本)
python_versions = py36, py38, py310
# 可选:如果需要限定平台,比如只保留通用跨平台包和Linux x86_64,可添加
# platforms = any, manylinux_2_17_x86_64

三、解决requests未下载的步骤

  1. 清理无效数据(可选但建议):
    之前同步的1.1TB数据包含大量不符合规则的包,直接删除存储目录内容以避免冗余:
    rm -rf /path/to/your/mirror/storage/*
    
  2. 重新同步:
    运行命令启动同步,这次会自动下载符合规则的requests包(包括requests-2.31.0.tar.gz和requests-2.31.0-py3-none-any.whl):
    bandersnatch mirror
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.07 05:47:32