我在 Windows 上使用此 cmd 将我的包上传到 testpypi
twine upload -r testpypi dist/*
但它显示此错误。那么启用 2FA 时如何在 testpypi 和 pypi 中上传?
Uploading mypackage-0.1.0-py3-none-any.whl
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.5/8.5 kB • 00:00 • ?
WARNING Error during upload. Retry with the --verbose option for more details.
ERROR HTTPError: 401 Unauthorized from https://test.pypi.org/legacy/
User has two factor auth enabled, an API Token or Trusted Publisher must be used to upload in place of password.
从您的 pypi 帐户创建 API 令牌,然后在 cmd 后给出
username =__token__
和 password=APIToken
twine upload -r testpypi dist/*
或 如果您使用 Twine 将项目上传到 PyPI,请像这样设置 $HOME/.pypirc 文件:
[testpypi]
username = __token__
password = API Token