如何修复 poetry publish HTTP Error 403: Invalid or non-existent authentication information
问题:
你打算使用 poetry 通过类似这样的命令在 PyPI 上发布你的包
poetry_publish.sh
poetry publish但是,你看到以下错误消息:
poetry_publish_403.txt
Publishing mypackage (0.1.0) to PyPI
- Uploading mypackage-0.1.0-py3-none-any.whl FAILED
HTTP Error 403: Invalid or non-existent authentication information. See https://pypi.org/help/#invalid-auth for more information. | b'<html>\n <head>\n <title>403 Invalid or non-existent authentication information. See https://pypi.org/help/#invalid-auth for more information.\n \n <body>\n <h1>403 Invalid or non-existent authentication information. See https://pypi.org/help/#invalid-auth for more information.\n Access was denied to this resource.<br/><br/>\nInvalid or non-existent authentication information. See https://pypi.org/help/#invalid-auth for more information.\n\n\n \n'解决方案
首先,如果你还没有 PyPI API 令牌,需要创建一个。用户名/密码认证已弃用。
现在运行以下命令配置 poetry:
poetry_config_token.sh
poetry config http-basic.pypi __token__ APITOKEN其中 APITOKEN 是你要在此计算机上使用的 API 令牌。保留 __token__ 不变,因为它是一个特殊用户名,告诉 PyPI 使用 API 令牌而不是旧的已弃用的用户名/密码认证
它应该看起来像这样:
poetry_config_token_example.sh
poetry config http-basic.pypi __token__ pypi-AgEIc[...]现在重试发布:
poetry_publish_retry.sh
poetry publish示例输出:
poetry_publish_success.txt
Publishing mypackage (0.1.0) to PyPI
- Uploading mypackage-0.1.0-py3-none-any.whl 100%
- Uploading mypackage-0.1.0.tar.gz 100%Check out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow