Python Versions

There exists a windows version for this tool as well. See the Windows section https://telin.ugent.be/telin-docs/windows/

This should also work for MacOS users.

Installing different python version in your system

We recommend to use pyenv if you struggle with various python language versions!

Install

#do not use sudo!
curl https://pyenv.run | bash

This will install the tool in your ~/.pyenv directory

Init your .profile

Issue this command to add it when you login:

cat >> ~/.profile << EOF
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
EOF

Restart your shell for the changes to take effect, logout/login or e.g. source ~/.profile

List python versions

pyenv install -l

Pick any version from the list to install

Let’s assume you want to have this specific pypy3.10-7.3.17 version:

pyenv install pypy3.10-7.3.17

Activate

pyenv shell pypy3.10-7.3.17
# ready to go!
python3 --version
Python 3.10.14 (39dc8d3c85a7, Aug 27 2024, 14:32:27)
[PyPy 7.3.17 with GCC 10.2.1 20210130 (Red Hat 10.2.1-11)]

Overrule the system python version

pyenv global pypy3.10-7.3.17

Set a specific version when you enter a directory

cd Downloads
pyenv local pypy3.10-7.3.17

python3 --version
Python 3.10.14 (39dc8d3c85a7, Aug 27 2024, 14:32:27)
[PyPy 7.3.17 with GCC 10.2.1 20210130 (Red Hat 10.2.1-11)]

cd ..
python3 --version
Python 3.12.3

pip3

By using pyenv we can flawlessly switch to any version in any directory. If you install packages with pip3, they will be installed in this specific version you use e.g. in our case under ~/.pyenv/versions/pypy3.10-7.3.17/lib/pypy3.10/site-packages If you want to separate the packages in a different directory, use a python virtual environment, in this case we create a venv directory:

python3 -m venv venv
. venv/bin/activate

Then your packages will be separatly placed in venv/lib/pypy3.10/site-packages.

(venv) $ pip3 install numpy
Collecting numpy
  Using cached numpy-2.1.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.1 MB)
Installing collected packages: numpy
Successfully installed numpy-2.1.1

(venv) $ ls venv/lib/pypy3.10/site-packages/
_distutils_hack           numpy                  numpy.libs  pip-23.0.1.dist-info  setuptools
distutils-precedence.pth  numpy-2.1.1.dist-info  pip         pkg_resources         setuptools-65.5.0.dist-info

Using pyenv and python virtual environments gives alot of flexibility to maintain python in your projects.