【问题标题】:403 Client Error: Invalid or non-existent authentication information while uploading to Pypi with twine403 客户端错误:使用 twine 上传到 Pypi 时验证信息无效或不存在
【发布时间】:2020-03-17 04:19:27
【问题描述】:

403 客户端错误:使用 Twine 将新模块上传到 pypi 时出现无效或不存在的身份验证信息

Win10 Pro 1803 Biuld 17134.1069 64 位 // Python 3.7.5 32 位 // pip 19.3.1

我成功创建了 tar。和whl。在 dist 文件夹中,在https://pypi.org/ 注册并通过电子邮件确认并开始上传。

我用命令行检查了两个文件('PASSED')

并做了以下事情:

Uploading distributions to https://upload.pypi.org/legacy/
Enter your username: gakonorde
Enter your password:
Uploading gersyll-Alpha.release-py3-none-any.whl
100%|█████████████████████████████████████████████████████████████████████████████| 6.43k/6.43k [00:01<00:00, 5.12kB/s]
NOTE: Try --verbose to see response content.
HTTPError: 403 Client Error: Invalid or non-existent authentication information. for url: https://upload.pypi.org/legacy/

命令行不允许我在用户名后输入密码。我只能按 ENTER。

我也试过了

Password for 'your-username' in 'https://upload.pypi.org/legacy/':

...再说一次,除了 ENTER,我什么都不能按。

然后我创建了 .pypirc 文件,其中包含 https://pypi.org/ 及其测试版本的凭据并再次运行 python -m twine upload dist/*

我没有被要求输入密码,但得到了同样的错误:

Uploading distributions to https://upload.pypi.org/legacy/
Uploading gersyll-Alpha.release-py3-none-any.whl
100%|█████████████████████████████████████████████████████████████████████████████| 6.43k/6.43k [00:01<00:00, 5.46kB/s]
NOTE: Try --verbose to see response content.
HTTPError: 403 Client Error: Invalid or non-existent authentication information. for url: https://upload.pypi.org/legacy/

当我将 .pypirc 与 API 令牌结合使用时,问题仍然存在。

我可以在https://pypi.org/ 上输入我的帐户,所以它显然存在(并且电子邮件已验证)。

我还添加了第二封电子邮件,经过验证并将其设置为主要电子邮件(没有任何变化)。

这是我的 setup.py:

import setuptools

with open("README.md", "r") as fh:
    long_description = fh.read()

setuptools.setup(
    name="gersyll",
    version="Alpha release",
    author="gakonorde",
    author_email="gabrielko@yandex.ru",
    description="This module counts the number of words of different syllable length for all texts in a directory",
    long_description=long_description,
    long_description_content_type="text/markdown",
    url="https://github.com/gakonorde/gersyll",
    packages=setuptools.find_packages(),
    classifiers=[
        "Programming Language :: Python :: 3.7",
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
    ],
    python_requires='>=3.7',
)

我做错了什么?

任何帮助将不胜感激。

编辑: .pypirc 文件与 .setup、README、License、dict/ 等位于同一文件夹中。

内容如下:

[distutils]
index-servers =
  pypi
  pypitest

[pypitest]
repository: testpypi.python.org/pypi
username: gakonorde 
password: [my_password]

[pypi]
repository: upload.pypi.org/legacy
username: gakonorde
password: [my_password]

【问题讨论】:

  • Enter your password: 提示之后您将看不到任何输入,因为它隐藏了您的密码。你把.pypirc 文件放在哪里了?您可以分享内容(密码已编辑)吗?
  • .pypirc文件与.setupREADMELicensedict/等在同一个文件夹,内容如下:``` [distutils] index-服务器 = pypi pypitest [pypitest] 存储库:testpypi.python.org/pypi 用户名:gakonorde 密码:[my_password] [pypi] 存储库:upload.pypi.org/legacy 用户名:gakonorde 密码:[my_password] ``` (在我的情况下,主要和文本版本Pypi 帐户名称相同,抱歉在这里格式化代码 - 我是 Stackoverflow 的新手)
  • 我已经编辑了您的问题,将来您可以在那里添加更新和说明。

标签: python upload http-status-code-403 pypi twine


【解决方案1】:

关于密码提示,在 Enter your password: 提示之后您将看不到任何输入,因为它隐藏了您的密码。

对于您的 .pypirc 文件,它应该位于您的主目录 (~/.pypirc) 中,而不是与您的 setup.py 文件位于同一目录中。

【讨论】:

  • 非常感谢,帮了大忙!
【解决方案2】:

解决了

python -m twine upload -u USERNAME -p PASSWORD dist/*

【讨论】:

    猜你喜欢
    • 2017-12-11
    • 2018-03-18
    • 1970-01-01
    • 1970-01-01
    • 2017-03-18
    • 1970-01-01
    • 2020-04-14
    • 2017-06-17
    • 2020-06-30
    相关资源
    最近更新 更多