Authentication error when using twine to upload to pypi

224 views Asked by At

I have a project on pypi which I have successfully uploaded to in the past using a ~/.pypirc file. However, I accidentally changed the ~/.pypirc file and I can no longer use twine to upload to pypi.

Here is the contents of my ~/.pypirc:

[distutils]
  index-servers =
    pypi
    PROJECT_NAME

[pypi]
  username = <username>
  password = <token given to me by pypi for a specific project>

[PROJECT_NAME]
  repository = https://upload.pypi.org/legacy/
  username = <username>
  password = <token given to me by pypi for a specific project>

Where I have replaced both username and token appropriately.

Error received when running twine upload <project_name>.tar.gz --verbose:

INFO     Using configuration from /home/<username>/.pypirc                                                                                                                                      
Uploading distributions to https://upload.pypi.org/legacy/
INFO     <project_name>.tar.gz (25.9 MB)                                                                                                                                               
INFO     username set from config file                                                                                                                                                        
INFO     password set from config file                                                                                                                                                        
INFO     username: <username>                                                                                                                                                                   
INFO     password: <hidden>                                                                                                                                                                   
Uploading <project_name>.tar.gz
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 27.2/27.2 MB • 00:00 • 74.7 MB/s
INFO     Response from https://upload.pypi.org/legacy/:                                                                                                                                       
         403 Invalid or non-existent authentication information. See https://pypi.org/help/#invalid-auth for more information.                                                                
INFO     <html>                                                                                                                                                                               
          <head>                                                                                                                                                                              
           <title>403 Invalid or non-existent authentication information. See https://pypi.org/help/#invalid-auth for more information.</title>                                               
          </head>                                                                                                                                                                             
          <body>                                                                                                                                                                              
           <h1>403 Invalid or non-existent authentication information. See https://pypi.org/help/#invalid-auth for more information.</h1>                                                     
           Access was denied to this resource.<br/><br/>                                                                                                                                      
                                                                                                                                                                                              
                                                                                                                                                                                              
                                                                                                                                                                                              
          </body>                                                                                                                                                                             
         </html>                                                                                                                                                                              
ERROR    HTTPError: 403 Forbidden from https://upload.pypi.org/legacy/                                                                                                                        
         Invalid or non-existent authentication information. See https://pypi.org/help/#invalid-auth for more information.

I am using the command: twine upload <project_name>.tar.gz

To generate this <project_name>.tar.gz file I did the following to the <project_name_directory> directory before compressing it:

  1. changed version numbers to a new version in all files
  2. ran python setup.py bdist_wheel to generate the <project_name>.whl which is now in the dist/ directory
  3. Ran tar -czvf <project_name_directory>.tar.gz <project_name_directory> to generate an archive and compress it
  4. Tried to run twine upload <project_name>.tar.gz

I expected this to work as it did previously but I am not sure what I am doing differently than last time.

I have also tried not using the ~/.pypirc file. This results in a prompt for a username and password for which I provided my username and the API token for the specific project. This results in identical output as above.

Any advice/help is appreciated! Thanks!

0

There are 0 answers