When I wanted to use Tensorflow I found out that it requires Python 3.6 and does not work with Python 3.7. However, Archlinux already uses Python 3.7. Besides, when Python 3.7 came out Scrapy also failed with 3.7, because twisted used async as variable names and Python 3.7 defined async as a reserved keyword.

Thus, I was confronted with installing a different version of Python. With virtual environments different versions of Python are simple to use, but you still have to install Python yourself first.

For this, go to the Python Releases page and download the version you want to install. Unzip the archive and change into the directory. In the directory execute:

./configure --prefix=$PATH_TO_INSTALL
make && make install

This will install python to $PATH_TO_INSTALL. I usually set this to a subfolder in $HOME/bin.

To simplify the installation I created a bash script that does all the work:

#!/usr/bin/env bash


wget -O $TMP_FOLDER/Python-$VERSION.tgz https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tgz

if [ $? -ne 0 ]; then
    echo "Could not download Python $VERSION"
    exit 1

mkdir -p $HOME/bin/python/$VERSION

    && ./configure --prefix=$HOME/bin/python/$VERSION \
    && make && make install \
    && cd $HOME

To use it just call it with the desired Python version as argument and it will install the Python version to $HOME/bin/python/$VERSION.

You can then setup a virtual environment with this Python version:

virtualenv -p $HOME/bin/python/$VERSION/bin/python3 env
I do not maintain a comments section. If you have any questions or comments regarding my posts, please do not hesitate to send me an e-mail to blog@stefan-koch.name.