twine: 403 Client Error: Invalid or non-existent authentication information.

Your Environment

  1. Your operating system: Ubuntu 18.10

  2. Version of python you are running:

Python 2.7.15+
  1. How did you install twine? Did you use your operating system’s package manager or pip or something else?

I followed instructions at https://pypi.org/project/twine/

pip install twine

Then when I tried to run it, I was instructed to run:

sudo apt install twine
  1. Version of twine you have installed (include complete output of):
twine version 1.11.0 (pkginfo: 1.4.2, requests: 2.18.4, setuptools: 40.2.0,
requests-toolbelt: 0.8.0, tqdm: 4.23.4)
  1. Which package repository are you targeting?

I don’t know what this means.

$ cat darip.egg-info/PKG-INFO 
Metadata-Version: 1.0
Name: darip
Version: 1.0.0
Summary: Bulk downloads images from Deviant Art
Home-page: https://github.com/kstenerud/darip/
Author: Karl Stenerud
Author-email: kstenerud@gmail.com
License: UNKNOWN
Description: UNKNOWN
Platform: UNKNOWN
$ cat ~/.pypirc 
cat: /home/karl/.pypirc: No such file or directory

The Issue

I get an HTTP error following the instructions at https://pypi.org/project/twine/

Steps to Reproduce

If the issue is predictable and consistently reproducible, please list the steps here.

$ twine upload --repository-url https://test.pypi.org/legacy/ dist/*
Uploading distributions to https://test.pypi.org/legacy/
Enter your username: kstenerud
Enter your password: 
Uploading darip-1.0.0-py2-none-any.whl
100%|██████████████████████████████████████████████████████████████████████████████████████████████████| 8.02k/8.02k [00:00<00:00, 9.58kB/s]
HTTPError: 403 Client Error: Invalid or non-existent authentication information. for url: https://test.pypi.org/legacy/

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 18 (5 by maintainers)

Most upvoted comments

Instead of twine upload --repository-url https://test.pypi.org/legacy/ dist/*

write twine upload --repository-url https://upload.pypi.org/legacy/ dist/*

I was also having same problem but by typing commands this way, my problem got solved.

@Foxgeek36 and @Kamleshgupta1:

The correct solution when --repository-url https://test.pypi.org/legacy/ fails due to Invalid or non-existent authentication information is to create an account on https://test.pypi.org/, which is “a separate instance of the Python Package Index that allows you to try distribution tools and processes without affecting the real index.”

Using --repository-url https://upload.pypi.org/legacy/ will upload your package to https://pypi.org/, which publishes it “for real”.

Instead of twine upload --repository-url https://test.pypi.org/legacy/ dist/*

write twine upload --repository-url https://upload.pypi.org/legacy/ dist/*

I was also having same problem but by typing commands this way, my problem got solved.

the perfect solution

hi, when we enter the password, the password is definitely not wrong and I think it’s a bug. so I try to use -u for the username and -p for the password directly without using the fields provided by the console (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 / * Capture_distribute_packages_upload_2 it really works for me. thanks:)

https://test.pypi.org/user/kstenerud/ does not exist. You have to create your login there first.

The error message could be improved by PyPI but is not in the domain of Twine in my opinion.

C:\python with ai\pykh>twine upload -u salah100 -p khizerkamranpp - repository-url https://test.pypi.org/legacy/ dist / * InvalidDistribution: Cannot find file (or expand pattern): ‘-’

Having verified accounts in PyPI and TestPyPI, contents for ~/.pypi:

[distutils]
index-servers=
    pypi
    testpypi

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

[testpypi]
repository: https://test.pypi.org/legacy/
username: ***
password: ***

After building the package, publishing for TestPyPI:

twine upload --repository testpypi dist/*

Publishing for PyPI:

twine upload --repository pypi dist/*

Thanks @vsay01 and @adamcanray this worked!

twine upload -u 'USERNAME' -p 'PASSWORD' --repository-url https://upload.pypi.org/legacy/ dist/*

Here are my other config options

.pypirc

[distutils]
  index-servers =
    pypi

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

.localrc

export TWINE_USERNAME=reubano
twine upload dist/*
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
twine upload --repository-url https://upload.pypi.org/legacy/ dist/* --password password