-
Notifications
You must be signed in to change notification settings - Fork 214
Installation of fmm (Python)
Can Yang edited this page Jan 31, 2020
·
20 revisions
- 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
- To install the python extension, under the project folder run
cd python
mkdir build
cd build
cmake ..
make
- Add the
build
folder to the environment variablePYTHONPATH
(set thePATH_TO_BUILD_FOLDER
below to the absolute path of thebuild
folder, e.g.,/home/Administrator/workspace/fmm/python/build
, you can runpwd
to check the absolute path of the current folder):
echo 'export PYTHONPATH=${PYTHONPATH}:PATH_TO_BUILD_FOLDER' >> ~/.bashrc
source ~/.bashrc
Run (from the build
folder)
# Change to the parent folder which contains fmm_test.py
cd ..
python fmm_test.py
- 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).
- 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
- Swig and Python documentation: http://www.swig.org/Doc1.3/Python.html#Python_nn13
- Swig and C++: http://www.swig.org/Doc4.0/SWIGPlus.html