A gravitational lensing software for modeling mass distribution of galaxies and clusters (strong and weak regime).

  • Credits: People who contribute on this project (in chronological order): Jean-Paul Kneib, Henri Bonnet, Ghyslain Golse, David Sand, Eric Jullo, Phil Marshall, Julien Zoubian, Mathilde Jauzac, Johan Richard, Benjamin ClĂ©ment, Tomas Verdugo, Soniya Sharma
  • Reference papers: Kneib et al 1996, Jullo et al 2007, Jullo & Kneib 2009


Starting from version 8, you can install Lenstool using conda on Linux and Mac OSX. This will give you access to the Python wrapper

conda install -c conda-forge lenstool
>>> import lenstool

On Ubuntu, you can also use the command apt-get from the command line.

apt-get install lenstool

On Mac OSX, you can use Macports (DEPRECATED)

sudo port install lenstool

On Windows you can use Cygwin, following the procedure described here.

Please note the following dependencies

They can be installed with the package managers.

Source Install

If you want to install a branch different from the master branch, you will have to install it from the source code. For this, we recommend to use a virtual environment, such as conda

conda create -n lenstool_env -c conda-forge wcslib cfitsio python astropy numpy gsl
conda activate lenstool_env

Then, you can clone the lenstool repository and checkout the branch you are looking for using the commands

git clone
cd lenstool
git checkout <name of the branch>

Finally, you can build and install lenstool with the commands

./configure --prefix=$CONDA_PREFIX --with-cfitsio-prefix=$CONDA_PREFIX --with-wcslib-include-path=$CONDA_PREFIX/include/wcslib --with-wcslib-lib-path=$CONDA_PREFIX/lib --with-gsl-prefix=$CONDA_PREFIX
make -j
make install
python3 -m pip install -vv --no-deps --ignore-installed .

Since version 6.8, Histogram and Histogram2D tools are not anymore compiled by default. You need to specify the option --with-pgplot to compile them. These tools also depend on X11 development libraries and fortran compiler, so you will have to install them before installing lenstool.

If you want to use the generalized NFW profile, you need to prepare the lookup table with this command

echo "0.01 1.70 0.01 0.01 30.0 1.01 " >
lenstool_tab ./
  • For Mac Users, you need to previously install XCode and the Command Line Tools.

Older versions

Please, contact Eric Jullo (eric.jullo AT, if you want to provide a compiled version with another operating system. Compiled version have been compiled with option --disable-shared.


lenstool AT

To be added to the mailing list contact Jean-Paul Kneib: jean-paul.kneib AT

Lenstool documentation

Lenstool Papers

Papers using lenstool to model the mass distribution of massive clusters (not exhaustive)


Finally, you can compile and install lenstool using the commands