pygmo has the following mandatory runtime dependencies:
Python 3.4 or later (Python 2.x is not supported),
the pagmo C++ library, version 2.19 or later,
the Boost serialization library, version 1.60 or later,
Additionally, pygmo has the following optional runtime dependencies:
pygmo packages are available from a variety of package managers on several platforms.
pygmo is available via the conda
package manager for Linux, OSX and Windows
thanks to the infrastructure provided by conda-forge.
In order to install pygmo via conda, you just need to add
to the channels, and then we can immediately install pygmo:
$ conda config --add channels conda-forge $ conda config --set channel_priority strict $ conda install pygmo
The conda packages for pygmo are maintained by the core development team, and they are regularly updated when new pygmo versions are released.
Please refer to the conda documentation for instructions on how to setup and manage your conda installation.
pygmo is also available on Linux via the pip package installer. The installation of pygmo with pip is straightforward:
$ pip install pygmo
If you want to install pygmo for a single user instead of system-wide, which is in general a good idea, you can do:
$ pip install --user pygmo
An even better idea is to make use of Python’s virtual environments.
The pip packages for pygmo are maintained by the core development team, and they are updated when new pygmo versions are released.
Note however that we strongly encourage users to install pygmo with conda rather than with pip. The reason is that pygmo is built on a moderately complicated stack of C++ libraries, which have to be bundled together with pygmo in the pip package. This is a problem if one uses pygmo together with other Python packages sharing dependencies with pygmo, because multiple incompatible versions of the same C++ library might end up being loaded at the same time, leading to crashes and erratic runtime behaviour. The conda packages do not suffer from this issue.
Any bug reported against the pip build and not reproduced with other installation methods (e.g., conda package, installation from source) will be automatically closed as invalid.
pygmo is available on the Arch User Repository (AUR) in Arch Linux. It is recommended to use an AUR helper like yay or pikaur for ease of installation. See the AUR helpers page on the Arch Linux wiki for more info.
$ yay -S python-pygmo
Installation from source#
In order to install pygmo from source, you will need:
a C++17 capable compiler (recent versions of GCC, Clang or MSVC should do),
a Python installation,
pybind11 (version >= 2.10),
the pagmo C++ library, (version >=2.19)
the Boost libraries,
CMake, version 3.18 or later.
After making sure the dependencies are installed on your system, you can
download the pygmo source code from the
GitHub release page. Alternatively,
and if you like living on the bleeding edge, you can get the very latest
version of pygmo via
$ git clone https://github.com/esa/pygmo2.git
We follow the usual PR-based development workflow, thus pygmo’s
branch is normally kept in a working state.
After downloading and/or unpacking pygmo’s
source code, go to pygmo’s
source tree, create a
build directory and
cd into it. E.g.,
on a Unix-like system:
$ cd /path/to/pygmo $ mkdir build $ cd build
Once you are in the
build directory, you must configure your build
cmake. There are various useful CMake variables you can set,
CMAKE_BUILD_TYPE: the build type (
Debug, etc.), defaults to
CMAKE_PREFIX_PATH: additional paths that will be searched by CMake when looking for dependencies.
PYGMO_INSTALL_PATH: the path into which the pygmo module will be installed. If left empty (the default), pygmo will be installed in the global modules directory of your Python installation.
PYGMO_ENABLE_IPO: set this flag to
ONto compile pygmo with link-time optimisations. Requires compiler support, defaults to
Please consult CMake’s documentation for more details about CMake’s variables and options.
PYGMO_INSTALL_PATH option is particularly important. If you
want to install pygmo locally instead of globally (which is in general
a good idea), you can set this variable to the output of
python -m site --user-site.
After configuring the build with CMake, we can then proceed to actually building pygmo:
$ cmake --build .
Finally, we can install pygmo with the command:
$ cmake --build . --target install
Verifying the installation#
You can verify that pygmo was successfully compiled and installed by running the test suite. From a Python session, run the following commands:
>>> import pygmo >>> pygmo.test.run_test_suite()
If these commands execute without any error, then your pygmo installation is ready for use.