Pyenv is a platform to install and manage different versions of Python, isolated from the default Python version. Its advantage compared to the other options, like Anaconda, is its simplicity and smallness. Currently, to build BornAgain libraries for different versions of Python, we use the pyenv platform.



Obtain the installer from To install pyenv, use

curl | bash

By default, pyenv is installed in $HOME/.pyenv.

The dependencies must be installed before building Python; see

sudo apt install build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev curl \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

Install pyenv via homebrew:

brew install pyenv

The rest of the pyenv instructions are like those for Linux.


On MS-Windows, pyenv-win should be used.

The available Python versions are distributed as binary, therefore one must choose the version from a given list.

The Python environments are installed by default under %USERPROFILE%\.pyenv\pyenv-win\versions.

To obtain the pyenv root, enter the following in cmd:


Using pyenv

Obtain a list of available Python versions

pyenv install --list

Obtain a list of available Python versions

pyenv install --list

Install a Python version To install a certain version, say 3.10, use:

pyenv install 3.10

List installed versions

pyenv versions

Obtain the pyenv root folder where all versions are stored

pyenv root

Obtain the path to the current version of Python in pyenv

pyenv which python3

Install Python packages for a certain version of Python

If the path to the Python executable is, for instance, $HOME/.pyenv/versions/3.10.12/bin/python3, then to install numpy for this specific Python version, one should use

$HOME/.pyenv/versions/3.10.12/bin/python3 -m pip install numpy

Build BornAgain with a specific Python version

To build BornAgain with a specific Python version, the path to the Python platform should be included in CMAKE_PREFIX_PATH variable; for instance, if Python 3.10.12 is installed in $HOME/.pyenv/versions/3.10.12 folder, then CMAKE_PREFIX_PATH should include this path.