[Newbie Tip] What to do when you 403 during pypi twine upload

I’m pretty new to the pypi packaging ecosystem so recently ran into some trouble pushing a python package:

$ python3 -m twine upload --repository testpypi dist/*

Uploading distributions to https://test.pypi.org/legacy/
Enter your username: swyx
Enter your password: 
Uploading smol_dev-0.1-py3-none-any.whl
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.4/7.4 kB • 00:00 • ?
WARNING  Error during upload. Retry with the --verbose option for more details.                                                                                                                   
ERROR    HTTPError: 403 Forbidden from https://test.pypi.org/legacy/                                                                                                                              
         Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information.                                         

This blocked me for a good several hours. A smart friend recommended using hatch and using a __token__ and api token auth scheme, which also did not work. ultimately what it was was that i was skimming thru instructions from the default python tutorial and didnt realize that test.pypi.org was a different package site than pypi.org. so just remove it:

$ python3 -m twine upload dist/*

also need to make sure that you dont use hyphens in your package name

- report-env
+ report_env

You can see my basic template repo at https://github.com/swyxio/report-env

Tagged in: #python

Leave a reaction if you liked this post! 🧡
Loading comments...
Webmentions
Loading...

Subscribe to the newsletter

Join >10,000 subscribers getting occasional updates on new posts and projects!

I also write an AI newsletter and a DevRel/DevTools newsletter.

Latest Posts

Search and see all content