Build ITK Module Python packages

ITK is organized into modules. Modules for ITK can be developed outside the ITK source tree as external modules. The external module can be made available in ITK’s CMake configuration by contributing it as a remote module. Python packages can also be generated for external modules and uploaded to the Python Package Index (PyPI)

This section describes how to create, build, and upload ITK external module Python packages to PyPI.


Building wheels requires:

  • CMake
  • Git
  • C++ Compiler - Platform specific requirements are summarized in scikit-build documentation.
  • Python

Create the module

To create an ITK module with Python wrapping, first run cookiecutter:

python -m pip install cookiecutter
python -m cookiecutter gh:InsightSoftwareConsortium/ITKModuleTemplate
# Fill in the information requested at the prompts

Then, add your classes. Reference documentation on how to populate the module can be found in the ITK Software Guide.

GitHub automated CI package builds

Freely available continous integration (CI) testing services for open source repositories on GitHub can be used to generate Linux, macOS, and Windows Python packages for your module.

After enabling builds for the GitHub repository with a CircleCI, TravisCI, and AppVeyor account, Python wheel packages will be available with the continuous integration builds. These services use the configurations generated by the ITKModuleTemplate.

CircleCI Python wheels

Linux Python package wheel links can be found in the CircleCI Artifacts tab after expanding the available folders.

TravisCI Python wheels

macOS Python package wheels can be downloaded by visiting to the link found in the build output. Note: this link may only be valid for the initial download.

AppVeyor Python wheels

Windows Python package wheel links can be found in the AppVeyor Artifacts tab.

Automated platform scripts

Automated scripts are available in this repository to build Python packages that are binary compatible with the Python distributions provided by, Anaconda, and package managers like apt or Homebrew. The following sections outline how to use the associated scripts for Linux, macOS, and Windows.

Once the builds are complete, Python packages will be available in the dist directory.


To build portable Python packages on Linux, first install Docker.

For the first local build, clone the ITKPythonPackage repository inside your and download the required ITK binary builds:

cd ~/ITKMyModule
git clone

For subsequent builds, just call the build script:



First, install the macOS Python distributions. This step requires sudo:

cd ~/ITKMyModule
git clone

Then, build the wheels:



First, install Microsoft Visual Studio 2015, Git, and CMake, which should be added to the system PATH environmental variable.

Open a PowerShell terminal as Administrator, and install Python:

PS C:\> Set-ExecutionPolicy Unrestricted
PS C:\> $pythonArch = "64"
PS C:\> iex ((new-object net.webclient).DownloadString(''))

In a PowerShell prompt, run the windows-build-wheels.ps1 script:

PS C:\Windows> cd C:\ITKMyModule
PS C:\ITKMyModule> git clone IPP
PS C:\ITKMyModule> .\ITKPythonPackage\scripts\windows-download-cache-and-build-module-wheels.ps1

Upload the packages to PyPI

First, register for an account on PyPI.

Next, create a ~/.pypirc file with your login credentials:

index-servers =



where <your-username> and <your-password> correspond to your PyPI account.

Then, upload wheels to the testing server:

python -m pip install twine
python -m twine upload -r pypitest dist/*

Check out the packages on the testing server.

Finally, upload the wheel packages to the production PyPI server:

python -m twine upload dist/*

Congratulations! Your packages can be installed with the commands:

python -m pip install --upgrade pip
python -m pip install itk-<yourmodulename>