How to use PyPi to distribute Python packages

1 minute read

Related: Replace/augment with pyproject.toml

This procedure has been updated to work with PyPi Warehouse and use the more secure and powerful twine uploader.

PyPi upload

This assumes you already have the and structure below

one-time setup

  1. Sign up for PyPi account.
  2. Install Twine
    python -m pip install twine
  3. create ~/.pypirc with the content

Note that I did NOT save my password for security.


  1. In your Python package directory to upload
    python sdist bdist_wheel
    twine upload dist/*
  2. Now your package is live to the world on PyPi. Anyone can install it via
    python -m pip install myprogram


  1. assuming your package is named myprogram, have a directory structure like
  2. A minimal for PyPi contains something like:
    #!/usr/bin/env python
    from setuptools import setup, find_packages
       version = '0.1.0',
       description='My program is 2x faster and 1/3 the size of Hello World.',
       author = 'Author Name',
       url = '',
       'Development Status :: 4 - Beta',
       'Programming Language :: Python',

    Pick from the list of classifiers suitable for your project.


  • you MUST increment the version number for each release, or PyPi will not let you upload
  • Markdown is enabled by setup(long_description_content_type="text/markdown")

Error workarounds

error: Upload failed (400): Binary wheel ‘*-cp36-cp36m-linux_x86_64.whl’ has an unsupported platform tag ‘linux_x86_64’.

You can workaround this by not uploading the wheel, just the source code and your users will compile it on their machine.

python sdist 
twine upload dist/*

Leave a Comment