Use PyPI to distribute Python packages

This procedure is for PyPI Warehouse and requires the twine uploader. Assuming a Python package named “myprogram”, have a directory structure like


A minimal setup.cfg and / or pyproject.toml are all that’s required for a PyPI Python package. You MUST increment the “version” number for each release, or PyPI will prevent upload.

PyPI upload

Ensure you have the prereqs:

pip install --upgrade pip setuptools twine wheel

one-time setup

Sign up for a PyPI account.

Create ~/.pypirc with the content


Do NOT save password for security.


In your Python package directory, create the source package and upload

python sdist

twine upload dist/*

Now the package is live to the world on PyPI, installable via pip install.


Error workarounds

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

This error happens because PyPI requires manylinux wheels. It is not trivial to first start building manylinux wheels. Consider not uploading the wheel. User will compile your source code on their machine. They will need the appropriate compilers and libraries for your Python package.