403 Client Error: Invalid or non-existent authentication information while uploading to Pypi with twine

403 Client Error: Invalid or non-existent authentication information while uploading to Pypi with twine

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/ 上注册并通过电子邮件确认并tar上传。

我用命令行检查了两个文件 ('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/

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

我也试过了

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]

已解决

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

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

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