Installation

Python 2 vs Python 3

particles is currently compatible with both Python 2 and Python 3. When Python 2 gets deprecated (around 2020) Python 2 support may be dropped.

Requirements

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).

Basic installation

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

pip install --user particles

It is best to install any package from PyPI without root privilege. 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).

Manual/Editable installation

The package is available on Github and may be installed using git:

cd some_folder_of_your_choosing
git clone https://github.com/nchopin/particles.git
pip install --user .

Replace option --user by -e if you want to install in editable mode; in that way you may edit yourself the package (in the folder you chose), and then import the modified version.

Troubleshooting

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

cd some_folder_of_your_choosing
git clone https://github.com/nchopin/particles.git
python setup.py 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.