Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Publishing to PyPI | Distribution & Publishing
Python Packaging and Distribution

bookPublishing to PyPI

Before you upload your distribution, ensure your package files are ready. You should have built distribution archives such as a source distribution (.tar.gz) and a wheel (.whl) using tools like build. These files are typically found in the dist/ directory of your project.

Security is crucial when publishing to PyPI.

  • Always use a strong, unique password for your PyPI account;
  • Enable two-factor authentication (2FA) for additional protection;
  • Never share your credentials or store them in your project repository;
  • Consider using a password manager to keep your login details secure.

To upload your package, you will use twine, which is a secure utility for publishing Python packages. Make sure you have twine installed in your environment.

# Upload your package to PyPI using twine
twine upload dist/*

After running this command, you will be prompted for your PyPI username and password. If you have enabled two-factor authentication (2FA), you will also need to provide your authentication code. Check the output for any errors, and verify your package is available on https://pypi.org/project/your-package-name/.

Note
Note

Review your package for sensitive files or credentials before uploading. Once a version is published to PyPI, it cannot be overwritten or deleted for security reasons, so double-check everything before you proceed.

question mark

What is a recommended security practice when publishing to PyPI?

Select the correct answer

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 3. Kapitel 3

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

bookPublishing to PyPI

Swipe um das Menü anzuzeigen

Before you upload your distribution, ensure your package files are ready. You should have built distribution archives such as a source distribution (.tar.gz) and a wheel (.whl) using tools like build. These files are typically found in the dist/ directory of your project.

Security is crucial when publishing to PyPI.

  • Always use a strong, unique password for your PyPI account;
  • Enable two-factor authentication (2FA) for additional protection;
  • Never share your credentials or store them in your project repository;
  • Consider using a password manager to keep your login details secure.

To upload your package, you will use twine, which is a secure utility for publishing Python packages. Make sure you have twine installed in your environment.

# Upload your package to PyPI using twine
twine upload dist/*

After running this command, you will be prompted for your PyPI username and password. If you have enabled two-factor authentication (2FA), you will also need to provide your authentication code. Check the output for any errors, and verify your package is available on https://pypi.org/project/your-package-name/.

Note
Note

Review your package for sensitive files or credentials before uploading. Once a version is published to PyPI, it cannot be overwritten or deleted for security reasons, so double-check everything before you proceed.

question mark

What is a recommended security practice when publishing to PyPI?

Select the correct answer

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 3. Kapitel 3
some-alt