Table Of Contents

Previous topic


Next topic


This Page


In the following we will try to keep a list of the various issues and fixes that might occur during installation.



from cern.madx import madx
ImportError: cannot open shared object file: No such file or directory

Solution: You can pass the correct path to the setup script when building:

python install --madxdir=<prefix>
# or alternatively:
python build_ext --rpath=<rpath>
python install

Where <prefix> is the base folder containing the subfolders bin, include, lib of the MAD-X build and <rpath> contains the dynamic library files.

If this does not work, you can set the LD_LIBRARY_PATH (or DYLD_LIBRARY_PATH on OSX) environment variable before running pymad, for example:


OSError: Missing source file


OSError: Missing source file: 'src/cern/cpymad/libmadx.c'. Install Cython to resolve this problem.

Solution: The easiest way to install Cython is:

pip install cython

Alternatively, you can install pymad from the PyPI source distribution which includes all source files.

Unable to find vcvarsall.bat


error: Unable to find vcvarsall.bat

Solution: Open or create the file C:\Python27\Lib\distutils\distutils.cfg and add the following lines:


If you do not want to modify your python system configuration you can place this as setup.cfg in the current directory.

TypeError: ‘NoneType’ object has no attribute ‘__getitem__’


Traceback (most recent call last):
  File "C:\Python27\lib\distutils\", line 227, in runtime_library_dir_option
    compiler = os.path.basename(sysconfig.get_config_var("CC"))
  File "C:\Python27\lib\", line 198, in basename
    return split(p)[1]
  File "C:\Python27\lib\", line 170, in split
    d, p = splitdrive(p)
  File "C:\Python27\lib\", line 125, in splitdrive
    if p[1:2] == ':':
TypeError: 'NoneType' object has no attribute '__getitem__'

Solution: Add the following line to C:\Python27\Lib\distutils\

 def _init_nt():
     """Initialize the module as appropriate for NT"""
     g = {}
     g['CC'] = 'gcc'
     _config_vars = g

unrecognized command line option ‘-mno-cygwin’


gcc: error: unrecognized command line option '-mno-cygwin'
error: command 'gcc' failed with exit status 1

Solution: In the file C:\Python27\Lib\distutils\ delete every occurence of the string -mno-cygwin in the class Mingw32CCompiler (about line 320). Depending on your version of distutils, for example:

@@ -319,11 +319,11 @@ class Mingw32CCompiler (CygwinCCompiler):
            entry_point = ''

-       self.set_executables(compiler='gcc -mno-cygwin -O -Wall',
-                            compiler_so='gcc -mno-cygwin -mdll -O -Wall',
-                            compiler_cxx='g++ -mno-cygwin -O -Wall',
-                            linker_exe='gcc -mno-cygwin',
-                            linker_so='%s -mno-cygwin %s %s'
+       self.set_executables(compiler='gcc -O -Wall',
+                            compiler_so='gcc -mdll -O -Wall',
+                            compiler_cxx='g++ -O -Wall',
+                            linker_exe='gcc ',
+                            linker_so='%s %s %s'
                                        % (self.linker_dll, shared_option,
        # Maybe we should also append -mthreads, but then the finished


@@ -320,7 +320,7 @@ class Mingw32CCompiler (CygwinCCompiler):
            entry_point = ''

        if self.gcc_version < '4' or is_cygwingcc():
-           no_cygwin = ' -mno-cygwin'
+           no_cygwin = ''
            no_cygwin = ''