How to use PyPi to distribute Python packages: 2017 edition

Minimal setup for PyPi

  1. assuming your package is named joesprog, have a directory structure like
  2. A minimal for PyPi contains something like:

     #!/usr/bin/env python
     from setuptools import setup
       version = '1.0',
       description='Joe says this program is cool.',
       author = 'Joe Doe',
       url = '',
       'Development Status :: 4 - Beta',
       'Programming Language :: Python',

You can find a list of classifiers here, pick the ones suitable for your project. At least you should have which Python version(s) your program is intended for.

Simple PyPi upload procedure

  1. Sign up for PyPi account. It may take several hours to get the confirmation email.
  2. create ~/.pypirc with the content

     index-servers =
     username=<your pypi username>

    Note that I did NOT save my password for security.

  3. In your Python package directory that you want to upload

     python sdist bdist_wheel upload

Now your package is live to the world on PyPi, and anyone can install it via

pip install joesprog


  • you MUST increment the version number for each release, or PyPi will not let you upload

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 upload

Leave a Comment