Managing parallel python installs using pyenv
pyenv install --list | grep 3.5.2
3.5.2
anaconda3-5.2.0
pypy3.3-5.2-alpha1-src
pypy3.3-5.2-alpha1
pyenv allows us to activate Python 3.5.2 only for this project and will do the compiling for us.
Install with:
pyenv install -v 3.5.2
N.B. my first build failed due to the correct version of OpenSLL not being found. I had a look at common build problems for pyenv and followed instructions for my system (Arch). I double checked I installed all dependencies and also made sure to point to the correct (older) version of OpenSLL. Long live downgrading.
LDFLAGS="-L/usr/lib/openssl-1.0" \
CFLAGS="-I/usr/include/openssl-1.0"\
pyenv install -v 3.5.2
Setting LDFLAGS and CFLAGS was necessary for successful compilation for me.
Activate as your global python version using:
pyenv global 3.5.2
(Go back with to the default system python installation using: pyenv global system).
Or only use 3.5.2 locally (recommended; assumes you are in our NMC project repo):
pyenv local 3.5.2
This creates a .python-version file.
From here on you can install packages with your preferred method, either straight into the 3.5.2. installation with pip, or in some virtual environment.
To ensure python indeed refers to the one selected with pyenv, add the following to your .bashrc or .zshrc:
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"