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

上传至PyPI的包安装时提示“No matching distribution found”问题排查

自制PyPI包上传成功但无法安装的问题解决

问题现象

包上传至PyPI成功,但执行安装命令时出现如下错误:

ERROR: Could not find a version that satisfies the requirement Google-Ads-Transparency-Scraper==1.4 (from versions: none)
ERROR: No matching distribution found for Google-Ads-Transparency-Scraper==1.4

项目目录结构

  • GoogleAds
    • GoogleAdsTransparency
      • init.py
      • main.py
      • regions.py
    • setup.py
    • setup.cfg
    • license.txt
    • README.md

相关配置文件内容

setup.py

"""Install packages as defined in this file into the Python environment."""
from setuptools import setup, find_packages

setup(
    name="Google Ads Transparency Scraper",
    author="Farhan Ahmed",
    author_email="jattfarhan10@gmail.com",
    url="https://github.com/faniAhmed/GoogleAdsTransparencyScraper",
    description="A scraper for getting Ads from Google Transparency",
    version="1.4",
    packages=find_packages(),
    download_url= 'https://github.com/faniAhmed/GoogleAdsTransparencyScraper/archive/refs/tags/v1.2.tar.gz',
    keywords= ['Google', 'Transparency', 'Scraper', 'API', 'Google Ads', 'Ads', 'Google Transparency', 'Google Transparency Scraper', 'Google Ads Scrapre'],
    license='Securely Incorporation',
    install_requires=[
        "setuptools>=45.0",
        "beautifulsoup4>=4.12.2",
        "Requests>=2.31.0",
        "lxml>=4.6.3",
    ],
    classifiers=[
        "Development Status :: 5 - Production/Stable",
        "Environment :: Console",
        "Intended Audience :: Developers",
        "License :: Free for non-commercial use",
        "Natural Language :: Urdu",
        "Operating System :: OS Independent",
        "Programming Language :: Python",
    ],
    platforms=["any"],
)

setup.cfg

[metadata]
description-file = README.md

init.py

from GoogleAdsTransparency.main import GoogleAds
from GoogleAdsTransparency.main import show_regions_list

上传命令

python setup.py sdist
twine upload dist/*

问题原因与解决步骤

核心问题

setup.py中的name参数使用了空格,PyPI会自动将空格转换为连字符(即Google-Ads-Transparency-Scraper),但本地打包生成的包元数据中名称仍为带空格的版本,导致pip查找时无法匹配对应版本。此外,download_url中的版本号与当前上传的1.4版本不匹配,也可能引发异常。

解决步骤

  1. 修正setup.py中的包名:将name参数改为与PyPI页面一致的名称:
    name="Google-Ads-Transparency-Scraper",
    
  2. 更新下载链接版本:将download_url替换为对应v1.4版本的GitHub标签链接:
    download_url= 'https://github.com/faniAhmed/GoogleAdsTransparencyScraper/archive/refs/tags/v1.4.tar.gz',
    
  3. 优化setup.cfg(可选但推荐):替换过时的description-file配置,支持README.md的正确渲染:
    [metadata]
    long_description = file: README.md
    long_description_content_type = text/markdown
    
  4. 重新打包并上传:
    # 清理旧的dist文件(可选)
    rm -rf dist/
    python setup.py sdist
    twine upload dist/*
    
  5. 执行安装命令:等待PyPI缓存更新后,重新运行安装命令即可正常安装。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.18 01:15:25