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?
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.
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.
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>
I ran into the same problem. I'm on a new OS X Sierra. Adding [server-login] entry to ~/.pypirc seemed to fix it http://www.seanbehan.com/how-to-fix-pypi-upload-failed-403-invalid-or-non-existent-authentication-information/
@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.
To the best of my knowledge, the behavior is working as expected.
@jaraco Thanks for the reply. I am using python 2.7 (homebrew python install on new mac book pro sierra) and the info from the docs you supplied does not work for me.
I have tried many variations and only [server-login] seems to work.
Same problem here, as well with homebrew on macOS Sierra
same for me, python2.7 only [server-login] seems to work, everything results in asking for password at upload, and then auth problem. Although same config, unchanged, same upload command, unchanged, same python major version (2.7) used to work a few months a go with config format @dover247 suggests
I just now attempted a new release and can report the exact same experience as @tgalal.
Thanks to @seanbehan for taking the time to post a workaround, which worked perfectly well for me.
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).
@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.
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?
@jaraco Thanks.
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.
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 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.
Getting this same issue with Python 3.6.1.
Having my .pypirc file:
[distutils]
index-servers =
pypi
[pypi]
repository: https://upload.pypi.org/legacy/
username: alcalyn
password:
The [distutils] section helped, though it seems like a setuptools bug that asks for a password that is never going to work without asking for a username. Also, the documentation at https://packaging.python.org/tutorials/distributing-packages/#uploading-your-project-to-pypi is wrong so...it took quite a bit of flailing to figure this out. The pypirc solution is great, but why doesn't setuptools prompt correctly from the command line in the first place?
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.
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
Same problem here, using:
Ubuntu 17.04
Python 2.7.13
why doesn't setuptools prompt correctly from the command line in the first place?
The upload command was originally implemented in distutils. Setuptools has only extended it. Nevertheless, in 20.10, Setuptools adds prompting support.
the documentation is wrong
If you think you can improve the guide, your help would be most appreciated. Please see the section on contributing to the guide.
I had similar problem but it turned out to be my repository parameter was wrong in my .pypirc file. And you do not need to specify repository any more. Once I removed it, my upload succeeded.
The same issue.
.pypirc
[distutils]
index-servers =
pypi
[pypi]
repository: https://upload.pypi.org/legacy/
username: left-join
password:
Trying to upload:
python setup.py sdist
...
python setup.py upload
Password:
error: No dist file created in earlier command
Ok, let's google & try again:
Trying to upload:
```bash
python setup.py sdist upload
...
Password:
Submitting dist/Flask-Settings-0.0.3.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.
The login/password pair is correct, I have just logged in with it.
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!
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.
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.
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.
I hit this same error. I changed my password on PyPI and was trying to use the new one. I can upload successfully with my old password. Seems like something is broken with password reseting.
If you get a Upload failed (403) response, make sure you have an account and can login on Pypi with the credentials you're using!
Mine weren't active yet, which gave me the 403 response.
By providing username and password in upload.py is worked for me.
PythonPython36-32Libdistutilscommandupload.py in the initialize_options() method in
upload class. Enter username and password. Then run command.
python setup.py sdist uploadThese docs don't mention the .pypirc: http://python-packaging.readthedocs.io/en/latest/minimal.html :(
These docs do: https://packaging.python.org/guides/migrating-to-pypi-org/#uploading :)
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?
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.
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.
@capooti You should have been getting an error message indicating that your email address needed verification, was this not the case?
@di I didn't get that message
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.
I made a .pypirc in my home directory
The contents were :
[server-login]
username:abc
password:xyz
Dint add repo
Worked for me
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.
BTW username != email in .pypirc.
I can't reproduce how I got confused, but I was under the impression python setup.py sdist upload and python setup.py bdist_wheel upload require configuration of different repositories. However, the following ~/.pypirc works for both:
[distutils]
index-servers =
pypi
[pypi]
username: danspypiuser
password: <password>
So how is this supposed to work in CI? Without access to home directory? How can I grab my creds out of env vars? How do I manage two pypi users?
edit: seems twine is the replacement for these tools
https://packaging.python.org/guides/distributing-packages-using-setuptools/#uploading-your-project-to-pypi
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/ ...
https://packaging.python.org/tutorials/packaging-projects/#uploading-the-distribution-archives currently says:
Finally, it鈥檚 time to upload your package to the Python Package Index!
The first thing you鈥檒l 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鈥檚 great for things like this tutorial where we don鈥檛 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.
I don't know how I missed that, but apparently it happened :smile:.
You can create a test.pypi.org account here: https://test.pypi.org/account/register/
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 onhttps://packaging.python.org/tutorials/packaging-projects/...
I agree with you!!! I also spend half an hour on it and find I don't do the registration for the test one.
Instead of
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
write
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
same error
.pypirc
[distutils]
index-servers =
pypi
[pypi]
repository: https://upload.pypi.org/legacy/
username: reubano
password:
Most helpful comment
Heres What I Did To Fix:
Created
~/.pypircFile With The Following Contents: