Installing Python 3.7 on Raspberry Pi
Installing Python 3.7.2 on Raspbian
Raspbian doesn't support the latest Python 3.7.2. This means you will have to build it from source.
Install the required build-tools.
sudo apt-get update -y sudo apt-get install build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev libffi-dev -y
If one of the packages cannot be found, try a newer version number (e.g.
Download and install the latest Python 3.7 source. Select the most recent release of Python (as of writing, 3.7.2) from the official site. Adjust the file names accordingly to match your version.
wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz tar xf Python-3.7.2.tar.xz cd Python-3.7.2 ./configure make -j 4 sudo make altinstall
You can use the newly installed python version by calling
pip3.7 install -e . and
python3.7 example.py respectively.