Python released its own library to Pypi Upload failed (403): Invalid or non-existent authentication information

Publish your own wheels-PyPI package upload practice

Upload failed (403): Invalid or non-existent authentication information

The reason for the error:, thepython setup.py sdist upload upload method is currently obsolete .

Solution: Use  twinetwine upload dist/*

 

This article only discusses the steps related to uploading. For how to write one setup.py , please refer to the official document:

Precautions before uploading

  • Assuming that your package has been developed, and there must be a setup.py in the root directory .
  • It is best to have a README.rst  to describe your wheels. Although this is not necessary, the document is like underwear, you better have it.
  • If you need to package files outside the code folder, such as copyright information, etc., you also need to write a  MANIFEST.in .

About setup.pysupplementary explanation

  • name It must be unique. Numbers and letters are allowed. It is recommended to use the underscore (-) instead of the underscore (_), because the pip installation only supports the underscore. For example pip install my-pkg, please be obedient in order not to trouble yourself.
  • versionIt is recommended to follow the semantic version number rule, which is simply like this: 1.2.0
  • The author’s name and email address do not have to be the same as your PyPI account.

Test local packaging commands

If none of the above is a problem, executing the following command in the local directory should be able to successfully generate the *.tar.gz package file in the dist directory.

python setup.py sdist

Upload and publish the package file to PyPI

Create a PyPI account

It's very simple. Register directly through the official website  https://pypi.python.org/pypi?... , but you need to verify the email and confirm the activation.

Create user authentication file ~/.pypirc

Create a new blank file in your user directory and name it as .pypircfollows:

[distutils]
index-servers=pypi

[pypi]
repository = https://upload.pypi.org/legacy/
username = <username>
password = <password>

The user name and password are those created in the previous step, and enter them directly in plain text. If you think the plaintext password is not safe, you can leave it blank, and you will be prompted to enter it manually during the upload process.

Register your package

You need to register and verify your package with PyPI before you can actually upload it. There are several ways to register.

  1. The use of commands is python setup.py registerthe simplest, but the official website is not recommended, because the use of HTTP is not encrypted, you may be sniffed by attackers to your password.
  2. Submit the form through the PyPI website to complete the registration verification.
  3. The installation  pip install twine then twine register dist/mypkg.whl completes the registration through the command  .

Upload and finish publishing

You can choose one of the following two ways to publish your wheels.

  1. Use the command:, the python setup.py sdist uploadsame as above, simple but with potential safety hazards, it has been eliminated at present .
  2. Use  twinetwine upload dist/*

Manage your package

If your package has been uploaded successfully, then when you log in to the PyPI website, you should be able to see the management entry in the navigation bar on the right.

pypi_manage

After clicking the package name, you can manage your package. Of course, you can also delete the package from here.

Let others use your bag

After the package is released, others only need to use pip to install your package file. such as:

pip install package-name

If you update the package, others can --updateupdate via parameters:

pip install package-name --update

Possible errors

Upload failed (403): Invalid or non-existent authentication information.

Wrong user authentication information, you need to create a user authentication file  ~/.pypirc. See above.

Upload failed (403): You are not allowed to edit 'xxx' package information

You need to register your package before you can start uploading, run the registration command:python setup.py register

Server response (401): Incomplete registration; check your email

Your PyPI account has not completed the email verification, you need to go to the registered email address to find a verification email to complete the verification and try the failed steps again.

Server response (400): Invalid classifier "Topic :: Software Development :: Utilities"

The classifier information in your setup.py file is wrong, please write the classifier according to the correct classification on the official website .

error: No dist file created in earlier command

You started the upload command before packaging. It is recommended that the packaging and uploading operations be done together, such as:

python setup sdist upload

error: Upload failed (499): Client Disconnected

This should be a network problem, try several times.

Upload failed (400): File already exists

The file already exists, and you should update the version number every time.

Reference documents

About the author: Python technology enthusiasts, currently engaged in test development related work, please indicate the original source.

Welcome to follow my blog  https://betacat.online , you can go to my official account to be the crowd.

Guess you like

Origin blog.csdn.net/xcntime/article/details/115189401