Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid or non-existent authentication information #941

Closed
tylerlong opened this issue Jan 24, 2017 · 52 comments
Closed

Invalid or non-existent authentication information #941

tylerlong opened this issue Jan 24, 2017 · 52 comments

Comments

@tylerlong
Copy link

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?

@tylerlong
Copy link
Author

tylerlong commented Jan 24, 2017

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.

@jaraco
Copy link
Member

jaraco commented Feb 3, 2017

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.

@dover247
Copy link

dover247 commented Feb 11, 2017

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>

@seanbehan
Copy link

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/

@jaraco
Copy link
Member

jaraco commented Mar 2, 2017

@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.

@jaraco
Copy link
Member

jaraco commented Mar 2, 2017

To the best of my knowledge, the behavior is working as expected.

@jaraco jaraco closed this as completed Mar 2, 2017
@seanbehan
Copy link

@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.

@koalalorenzo
Copy link

Same problem here, as well with homebrew on macOS Sierra

@tgalal
Copy link

tgalal commented Mar 23, 2017

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

@aphearin
Copy link

aphearin commented Mar 23, 2017

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.

@jaraco
Copy link
Member

jaraco commented Mar 26, 2017

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).

@seantrue
Copy link

@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.

@boxed
Copy link

boxed commented May 5, 2017

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?

@tao12345666333
Copy link

@jaraco Thanks.

@jaraco
Copy link
Member

jaraco commented Jun 17, 2017

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.

@reteps
Copy link

reteps commented Jun 28, 2017

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

@lebedov
Copy link

lebedov commented Jul 7, 2017

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.

@alcalyn
Copy link

alcalyn commented Jul 7, 2017

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:

@mrooney
Copy link

mrooney commented Jul 10, 2017

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?

@boxed
Copy link

boxed commented Jul 10, 2017 via email

@alcalyn
Copy link

alcalyn commented Jul 10, 2017

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

@fpelliccioni
Copy link

Same problem here, using:

Ubuntu 17.04
Python 2.7.13

@jaraco
Copy link
Member

jaraco commented Jul 26, 2017

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.

@quietcricket
Copy link

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.

@ghost
Copy link

ghost commented Sep 10, 2017

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.

@alejandrobll
Copy link

alejandrobll commented Sep 12, 2017

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!

@Noxalk

This comment has been minimized.

@JesseAldridge
Copy link

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.

@duhaime
Copy link

duhaime commented Dec 19, 2017

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.

@jeevan449
Copy link

By providing username and password in upload.py is worked for me.
\Python\Python36-32\Lib\distutils\command\upload.py in the initialize_options() method in
upload class. Enter username and password. Then run command.

python setup.py sdist upload

@charlesreid1
Copy link

@cnobile2012
Copy link

cnobile2012 commented May 5, 2018

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?

@d-rams
Copy link

d-rams commented May 21, 2018

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.

@capooti
Copy link

capooti commented May 22, 2018

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.

@di
Copy link
Sponsor Member

di commented May 22, 2018

@capooti You should have been getting an error message indicating that your email address needed verification, was this not the case?

@capooti
Copy link

capooti commented May 23, 2018

@di I didn't get that message

@tutuca
Copy link

tutuca commented May 28, 2018

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.

@Mr-Optimistic
Copy link

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

Dint add repo

Worked for me

@cnobile2012
Copy link

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.

@DusanMadar
Copy link

BTW username != email in .pypirc.

@dansgithubuser
Copy link

dansgithubuser commented Aug 7, 2018

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

@dschrempf
Copy link

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/ ...

@di
Copy link
Sponsor Member

di commented Dec 4, 2018

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.

@dschrempf
Copy link

I don't know how I missed that, but apparently it happened 😄.

@fabioespinosa
Copy link

You can create a test.pypi.org account here: https://test.pypi.org/account/register/

@JiaxiangBU
Copy link

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 agree with you!!! I also spend half an hour on it and find I don't do the registration for the test one.

@ops-gaurav
Copy link

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

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

@reubano
Copy link

reubano commented Nov 7, 2019

same error

.pypirc

[distutils]
  index-servers =
    pypi

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

@thebalaa
Copy link

If you are using an api token make sure to set user as __token__

@funny-cat-happy
Copy link

If you are using an api token make sure to set user as __token__

And you ,my friend,you are the true hero!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests