setuptools: Invalid or non-existent authentication information

When I run python setup.py sdist upload

I always get:

Submitting dist/xxxxxxx-0.1.4.tar.gz to https://upload.pypi.org/legacy/
Upload failed (403): Invalid or non-existent authentication information.
error: Upload failed (403): Invalid or non-existent authentication information.

It never asks me to enter my username but only password. So I assume the username is the same as when I run “register”.

I am pretty sure that password I entered is correct because I can login https://pypi.python.org/pypi

Could you please help? I am not new to pypi. I published several packages before. But now I am confused. What has changed recently?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 14
  • Comments: 52 (8 by maintainers)

Most upvoted comments

Heres What I Did To Fix:

Created ~/.pypirc File With The Following Contents:

[distutils]
index-servers =
    pypi

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

The very existence of this issue, the number of people commenting, etc, shows this stuff is really quite bad 😦

Could someone explain why https://upload.pypi.org/legacy/ is a URL that we should/can use?

OK, I have got it done.

I turns out that I have to create ~/.pypirc

Entering password in terminal just doesn’t work. It’s very likely a bug. Because password is correct and it didn’t give me chance to enter username.

Well, the server-login workaround is a bad one, and it will probably break at some point. I wonder if this issue has emerged due to the fairly recent changes to support warehouse. Setuptools patches upload to use https://upload.pypi.org/legacy/ as the default repository (instead of https://pypi.python.org/pypi.

For what it’s worth, I upload packages to PyPI at least weekly. I use the latest setuptools and Python and my pypirc looks like this:

[distutils]
index-servers =
    pypi

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

There’s no password entry because I rely on the keyring support to resolve the password (and store it securely).

It also took me an hour to realize that one needs a separate account for https://test.pypi.org/. This should definitely be stated in the tutorials on https://packaging.python.org/tutorials/packaging-projects/

I had the same problem @cnobile2012, until I realized I needed a separate registration, login etc. for test as well as the regular pypi server.

@tgalal The critical change for me was in @jaraco 's latest comment. I changed repository: https://pypi.python.org/pypi to repository: https://upload.pypi.org/legacy/ and everything worked as promised.

Somehow I get the same error while using Travis deploy and I am pretty sure I recorded the credentials correctly. I am afraid that in this case I cannot use the ~/.pypirc trick.

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

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

I fixed the problem by following the instructions written down here: https://packaging.python.org/guides/migrating-to-pypi-org/#uploading.

In my case, I used distutils 2.7.13, and removed the repository line from my ~/.pypirc file:

[distutils] index-servers = pypi

[pypi] username: your username password: your password

Hope this helps!

Well I made it work by trying many times with different settings, I think that doing a chmod 600 on this, putting it in ~/.pypirc and restarting bash was the right things

I observed the Upload failed (403): Invalid or non-existent authentication information error using the same .pypirc file as @reteps, but only when I ran setup.py with Python 2.7; using Python 3.4, I was able to build the source tarball, wheel, and upload without any problems.

I’m able to upload my package to https://upload.pypi.org/legacy/, but not to https://test.pypi.org/legacy/. The username and password are the same, but it just doesn’t let me upload the file. I get the response: HTTPError: 403 Client Error: Invalid or non-existent authentication information. for url: https://test.pypi.org/legacy/

I’ve tried entering the username and password manually and using the settings in the .pypirc file.

Any ideas where the issues is?

It’s not working for me. This is my file:

[distutils]
index-servers = 
  pypi

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

gives me this error

Submitting dist/cityinfowrapper-1.0.0.tar.gz to https://upload.pypi.org/legacy/
Upload failed (403): Invalid or non-existent authentication information.
error: Upload failed (403): Invalid or non-existent authentication information.

when I run python3 setup.py sdist upload.

The full thing is:

running sdist
running egg_info
writing cityinfowrapper.egg-info/PKG-INFO
writing dependency_links to cityinfowrapper.egg-info/dependency_links.txt
writing requirements to cityinfowrapper.egg-info/requires.txt
writing top-level names to cityinfowrapper.egg-info/top_level.txt
file cityinfowrapper/py.py (for module cityinfowrapper.py) not found
reading manifest file 'cityinfowrapper.egg-info/SOURCES.txt'
writing manifest file 'cityinfowrapper.egg-info/SOURCES.txt'
running check
creating cityinfowrapper-1.0.0
creating cityinfowrapper-1.0.0/cityinfowrapper
creating cityinfowrapper-1.0.0/cityinfowrapper.egg-info
copying files to cityinfowrapper-1.0.0...
copying README.txt -> cityinfowrapper-1.0.0
copying setup.py -> cityinfowrapper-1.0.0
copying cityinfowrapper/__init__.py -> cityinfowrapper-1.0.0/cityinfowrapper
copying cityinfowrapper.egg-info/PKG-INFO -> cityinfowrapper-1.0.0/cityinfowrapper.egg-info
copying cityinfowrapper.egg-info/SOURCES.txt -> cityinfowrapper-1.0.0/cityinfowrapper.egg-info
copying cityinfowrapper.egg-info/dependency_links.txt -> cityinfowrapper-1.0.0/cityinfowrapper.egg-info
copying cityinfowrapper.egg-info/requires.txt -> cityinfowrapper-1.0.0/cityinfowrapper.egg-info
copying cityinfowrapper.egg-info/top_level.txt -> cityinfowrapper-1.0.0/cityinfowrapper.egg-info
Writing cityinfowrapper-1.0.0/setup.cfg
Creating tar archive
removing 'cityinfowrapper-1.0.0' (and everything under it)
running upload
Password: 
Submitting dist/cityinfowrapper-1.0.0.tar.gz to https://upload.pypi.org/legacy/
Upload failed (403): Invalid or non-existent authentication information.
error: Upload failed (403): Invalid or non-existent authentication information.

running pip3 install cityinfowrapper gives me:

Collecting cityinfowrapper
  Could not find a version that satisfied the requirement cityinfowrapper (from versions: )
No matching distribution found for cityinfowrapper

I made a .pypirc in my home directory The contents were : [server-login] username:abc password:xyz

Dint add repo

Worked for me

So there is no way to upload the package from command line only. There is no way to workaround the need of a .pypirc? Most CI tools don’t allow custom files in the home folder, so you have to rely on hacky steps like echo the file on some job.

The legacy URL is something that the new Warehouse service provides for compatibility with Python (distutils). That URL will continue to work after PyPI.python.org is removed.

@seanbehan: That [server-login] section is for old versions of Python (Python 2.5 and earlier if I recall correctly). Late versions still support this format, but I definitely recommend against it. Did you try the approach with the [distutils] section? Official docs are here.

I was looking through this code recently. I think if there’s no pypirc entry present, an empty username is used. The behavior exists upstream in distutils.

I did draft a change which would allow the username to default to getpass.getuser(), which is often a good default and which can be readily overridden with an environment variable.

I’ll send a PR for review.

https://packaging.python.org/tutorials/packaging-projects/#uploading-the-distribution-archives currently says:

Finally, it’s time to upload your package to the Python Package Index!

The first thing you’ll need to do is register an account on Test PyPI. Test PyPI is a separate instance of the package index intended for testing and experimentation. It’s great for things like this tutorial where we don’t necessarily want to upload to the real index. To register an account, go to https://test.pypi.org/account/register/ and complete the steps on that page.

Is there somewhere else that would be better for that information? Seems like it’s in the right spot to me.

BTW username != email in .pypirc.

After reading a few posts to this thread @Mr-Optimistic provided the answer to my issue. Up until now, I didn’t know there was the directive [server-login]. After adding that to my .pypirc file everything seems to know work.

I lost one hour on this and then I figured out that both my test and upload accounts (which used to work before) had an unverified email. After verifying the email everything works expected as it used to be.

I was with the same problem and then i opened the upload.py and edited: self.username and self.password

def initialize_options(self): PyPIRCCommand.initialize_options(self) self.username = 'put your user' self.password = 'put your password' self.show_response = 0 self.sign = False self.identity = None

i hope to have help them.

How is this done through windows? It’s beyond me pypa thought it would be a good idea to supply an empty username when you try uploading via the command line.

It could also prompt to write the data into the pypirc file. There seems to be many super trivial changes that can be made to make this a lot better.