Can't upload to PyPi with Twine

2020-08-13 05:43发布

I'm trying to upload a python package to PyPi, using the following commands:

pip install -e .
python setup.py bdist_wheel --universal
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*

I get this error:

HTTPError: 403 Client Error: Invalid or non-existent authentication information. for url: https://upload.pypi.org/legacy/

I've also tried the following commands:

twine upload dist/*
twine upload --repository-url pypi dist/*
twine upload --repository-url https://upload.pypi.org/legacy dist/*
python setup.py bdist_wheel --universal upload

with a .pypirc file located in the same directory I'm running the commands from which is:

[distutils]
index-servers =
    pypi
    pypitest

[pypitest]
repository: https://testpypi.python.org/pypi/
username: <username>
password: <password>

[pypi]
repository: https://upload.pypi.org/legacy/
username: <username>
password: <password>

But I'm still asked for my password. (Also tried this using pypitest, after creating an account on there too, but get the same error)

I've also tried doing the same but with the repository line removed.

The package name I'm trying to upload used to be occupied, but it has been removed now - https://pypi.python.org/pypi?name=&version=1.0.0&:action=display says that the package is not found

The username and password I'm using are the same I use to successfully log in to https://pypi.python.org/pypi?%3Aaction=login_form

7条回答
啃猪蹄的小仙女
2楼-- · 2020-08-13 05:55

When we enter the password, the password is not wrong, and I think it's a bug.

I use -u for the username and -p for the password directly without using the fields provided by the console(the default).

I try to run this in the command: twine upload -u YOUR-USERNAME -p YOUR-PASSWORD - repository-url https://test.pypi.org/legacy/ dist / *

I run that command on windows

It works for me. Hope this will help

查看更多
我只想做你的唯一
3楼-- · 2020-08-13 05:55

An alternative could have been that copying and pasting wasn't working - when I try to paste the password in the command line it showed this error, but when I typed it out manually it succeeded.

查看更多
趁早两清
4楼-- · 2020-08-13 05:58

PyPi and TestPyPi are separate instances of the package index which have separate user databases. Therefore, separate accounts must be created.

Maybe you'll get lucky and the test account name won't be taken and you can use the same commands in test as in production.

(Grumble, grumble, zen of python, grumble....)

查看更多
手持菜刀,她持情操
5楼-- · 2020-08-13 06:01

It looks like some sort of error with the account I was using. The following steps fixed it for me:

  1. Create a new account
  2. Upload the package with the new account with twine upload dist/*
  3. Add the previous account (that you originally wanted to upload with) to the package as an owner

Also be aware that the test pypi server --repository-url https://test.pypi.org/legacy/, requires a different account to be created from the live server --repository-url https://upload.pypi.org/legacy/

查看更多
Lonely孤独者°
6楼-- · 2020-08-13 06:04

I hit this problem following the pypi instructions for creating a new package. That tutorial takes you through uploading to their test server (--repository-url https://test.pypi.org/legacy/), for which I always get a 403.

For their actual uploads server, (--repository-url https://upload.pypi.org/legacy/) my credentials work fine. So clearly there's some variation in credentials between their test and live servers, which could be worth considering if you're bumping against this problem.

查看更多
神经病院院长
7楼-- · 2020-08-13 06:15

Type in the password manually. Seems dumb but it worked for me.

查看更多
登录 后发表回答