Skip to content

Installation of fmm (Python)

Can Yang edited this page Jan 31, 2020 · 20 revisions

Installation of Python program

Requirements

  • Linux/Unix environment (tested on Ubuntu 14.04), Windows (tested with Cygwin) and Mac (10.13.2).
  • swig 4.0.0
  • Python 2.7

Install requirements on Ubuntu with

sudo apt-get install swig python-dev

or on Cygwin run

apt-cyg install swig python-devel

on Mac run

brew install swig

Installation

  1. To install the python extension, under the project folder run
    cd python
    mkdir build
    cd build
    cmake ..
    make
  1. Add the build folder to the environment variable PYTHONPATH (set the PATH_TO_BUILD_FOLDER below to the absolute path of the build folder, e.g., /home/Administrator/workspace/fmm/python/build, you can run pwd to check the absolute path of the current folder):
    echo 'export PYTHONPATH=${PYTHONPATH}:PATH_TO_BUILD_FOLDER' >> ~/.bashrc
    source ~/.bashrc

Verification of installation

Run (from the build folder)

    # Change to the parent folder which contains fmm_test.py
    cd ..
    python fmm_test.py

Some screenshots

Screenshot

Common error with the installation

  1. ImportError: No module named fmm
  File "fmm_test.py", line 1, in <module>
    import fmm
  ImportError: No module named fmm

Make sure that the build folder is added to the environment variable PYTHONPATH as shown above (step 2 of installation).

  1. ImportError: dynamic module does not define init function (init_fmm)
ImportError: dynamic module does not define init function (init_fmm)

it can be caused by multiple version of Python installed. Make sure that the default python version

which python

is the same as the Python library used in cmake build. When the following command is executed, the Python location will be printed.

cmake ..  

If you have multiple version of Python installed, you can specify a specific version with

cmake .. -DPYTHON_LIBRARY=/anaconda2/lib/libpython2.7.dylib

Reference