首页 > 解决方案 > 为什么我不能使用 pypi 安装我的包并且我有错误?

问题描述

这是我的 icaptcha 包的 setup.py,它可以创建简单的图像验证码

import pathlib
from setuptools import setup

# The directory containing this file
HERE = pathlib.Path(__file__).parent

# The text of the README file
README = (HERE / "README.md").read_text()

# This call to setup() does all the work
setup(
    name="ICaptcha",
    version="2.0.0",
    description="Create Simple Image Captcha For Normal Use",
    long_description=README,
    long_description_content_type="text/markdown",
    url="https://github.com/imanhpr/ICaptcha",
    author="Iman Hosseini Pour",
    author_email="imanhpr1999@gmail.com",
    license="MIT",
    classifiers=[
        "License :: OSI Approved :: MIT License",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.8",
    ],
    packages=['icaptcha'],
    include_package_data=True,
    install_requires=["pillow"],

)

我在 pypi 中上传了它,当我尝试安装我的包时,我看到了这个错误

pip install icaptcha
ERROR: Could not find a version that satisfies the requirement string (from ICaptcha) (from versions: none) 
ERROR: No matching distribution found for string (from ICaptcha)

这是什么错误,我该如何解决?

标签: pythonmodulepackagesetuptoolssetup.py

解决方案


您将包上传到 Test PyPI:https ://test.pypi.org/project/ICaptcha/

但不是 PyPI:https ://pypi.org/project/ICaptcha/返回错误 404。

要使用来自 PyPI 的依赖项从 Test PyPI 安装:

pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ ICaptcha

或者上传到 PyPI 并重复

pip install ICaptcha

推荐阅读