In the following we will try to keep a list of the various issues and fixes that might occur during installation.
Message:
from cern.madx import madx
ImportError: libmadx.so: cannot open shared object file: No such file or directory
Solution: You can pass the correct path to the setup script when building:
python setup.py install --madxdir=<prefix>
# or alternatively:
python setup.py build_ext --rpath=<rpath>
python setup.py 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:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/.local/lib/
Message:
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.
Message:
error: Unable to find vcvarsall.bat
Solution: Open or create the file C:\Python27\Lib\distutils\distutils.cfg and add the following lines:
[build]
compiler=mingw32
If you do not want to modify your python system configuration you can place this as setup.cfg in the current directory.
Message:
Traceback (most recent call last):
...
File "C:\Python27\lib\distutils\unixccompiler.py", line 227, in runtime_library_dir_option
compiler = os.path.basename(sysconfig.get_config_var("CC"))
File "C:\Python27\lib\ntpath.py", line 198, in basename
return split(p)[1]
File "C:\Python27\lib\ntpath.py", line 170, in split
d, p = splitdrive(p)
File "C:\Python27\lib\ntpath.py", 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\sysconfig.py:
def _init_nt():
"""Initialize the module as appropriate for NT"""
g = {}
...
g['CC'] = 'gcc'
...
_config_vars = g
See also
Message:
gcc: error: unrecognized command line option '-mno-cygwin'
error: command 'gcc' failed with exit status 1
Solution: In the file C:\Python27\Lib\distutils\cygwinccompiler.py 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):
else:
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,
entry_point))
# Maybe we should also append -mthreads, but then the finished
or:
@@ -320,7 +320,7 @@ class Mingw32CCompiler (CygwinCCompiler):
entry_point = ''
if self.gcc_version < '4' or is_cygwingcc():
- no_cygwin = ' -mno-cygwin'
+ no_cygwin = ''
else:
no_cygwin = ''