Python 2 vs Python 3

Short version: particles only supports Python 3.

Long version: initially, particles supported both Python 2 and Python 3. However, Python 2 has been deprecated, and supporting it has become troublesome. The last version to support it has been turned into a release; you may find in the releases section of the github page (first release, April 15, 2020).


The short version: install The Anaconda distribution to get all the scientific computing libraries you may ever need in one go.

The long version: particles requires the following libraries:

In addition, it is strongly recommended to install the following plotting libraries:

Most of the examples require these libraries to plot results.

Again, the easiest way to install all these libraries in one go is to simply install the Anaconda distribution. Manual installation is of course also possible; e.g. on Ubuntu/Debian:

sudo apt install python-numpy python-scipy python-numba python-matplotlib python-seaborn

However, in the maintainer’s experience, conda is usually less hassle, and runs faster (because it install a more efficient version of low-level libraries such as BLAS).

Installation: a simpler method

The package is also available on PyPI (the Python package index), so you may install it by running pip. On a Linux machine:

pip install --user particles

Option --user lets you install the package in your home directory, rather than globally for all users.

The only drawback of this method is that it install only the modules of the package, and not the additional examples (e.g. the datasets and scripts that were used to generate the plots found in the book).


If the two methods above fail, you may try this:

cd some_folder_of_your_choosing
git clone
python install --force

This will install the package, without compiling the little bit of Fortran code that is used in module qmc. At this stage, you may already use the package if you do not use anything related to quasi-Monte Carlo (i.e. option qmc in class SMC). In addition, you may compile manually the said piece of Fortran as follows:

pip show particles  # tells you the folder where the package is installed
cd where_particles_is_installed/particles
f2py3 -c ../src/LowDiscrepancy.f -m lowdiscrepancy

Replace f2py3 by f2py if you use Python 2. Make sure a Fortran compiler is installed on your machine (e.g. package gfortran on Ubuntu). Utility f2py is part of Numpy; see here.