如何修复 Poetry publish HTTP Error 403: Invalid or non-existent authentication information

问题:

当你运行 poetry publish 时,你得到如下错误:

poetry_publish_403_error_output.txt
Publishing UliEngineering (0.4.19) to PyPI
 - Uploading uliengineering-0.4.19-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'

解决方案

使用 poetry 登录 PyPI(错误消息告诉你再次登录,即使你已经登录过)。你需要 PyPI API 令牌,而不是你的 PyPI 密码。如果你没有令牌,请在 PyPI 上创建一个。

poetry_config_token.sh
poetry config pypi-token.pypi pypi-.....

然后,再次尝试发布:

poetry_publish_build.sh
poetry publish --build

Check out similar posts by category: Python