Cython binding to MAD-X

pip install cpymad==1.9.3



Latest Version Python versions Supported platforms License: Source: CC0, Apache | Binary: Non-Free GitHub Actions Status Coverage DOI and Citation

cpymad is a Cython binding to MAD-X for giving full control and access to a MAD-X interpreter in python.

Note: Support for 32bit builds and python 2.7 has been removed in version 1.8.0.

Note: python 3.5 and manylinux1 have reached EOL. Support will be removed in a future release.



The cpymad source code itself is under free license, see COPYING.rst.

However, the MAD-X software package and henceforth all binary cpymad package distributions are NOT FREE., see MAD-X license.


The full changelog is available online in CHANGES.rst.

Reporting issues

Note that cpymad links against a custom build of MAD-X that may differ from the official CERN command line client. This binary may have problems that the official binary does not have and vice versa.

Therefore, before reporting issues, please make sure that you report to the correct recipient. First try to check if that problem remains when using the MAD-X command line client distributed by CERN, then report the issue:

  • to CERN if it can be reproduced with the official MAD-X executable
  • to us if it can not be reproduced with the official MAD-X executable

Please keep the code in the bug report as minimal as possible, i.e. remove everything that can be removed such that the issue still occurs. This will save us some effort in handling the error report.

Please post the code inline, don't upload zip files, or link to external sources, if possible.

Bug reports should describe the issue and contain a minimal python script similar to this:

from cpymad.madx import Madx
m = Madx()'commands.madx')

as well as the content of the commands.madx file.

You can create this file from your original python code with a minimal change that tells cpymad to write all MAD-X commands to a file:

m = Madx(command_log='commands.madx')

Now run this file with the official MAD-X command line client:

madx commands.madx

If madx reports the same error, check if there are any syntax errors in the commands.madx file. These may result from incorrect usage of cpymad, or bugs in cpymad.