'Twine upload credentials not update, HTTPError 401 Unauthorized

Problem description

My access token to private python package registry expired. Before everything worked well. I have defined .pypirc file as follows:

[distutils]
index-servers =
    gitlab

[gitlab]
repository = <my-repo-url>
username = <access-token-name>
password = <token>

To upload new release I just ran

python -m twine upload --repository gitlab dist/*

After my access token expired I got 401 Unauthorized error. I just tried to generate new token and replace old values in my .pypirc file.

I am still getting 401 Unauthorized error, I tried to run command with --verbose flag, and noticed that twine still tries to use old credentials.

I can successfully upload new distribution with manually defining my new token and username

python3 -m twine upload --repository gitlab dist/* -u <token-name> -p <token>

Why is that? How it can be fixed?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source