一、更新树莓派系统


sudo apt-get update
sudo apt-get upgrade

二、安装python需要的依赖


sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev

三、下载Python的源代码并解压


cd /usr/local/src
wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
tar zxvf Python-3.7.4.tgz

四、配置、编译、安装


sudo mkdir /usr/local/python
sudo ./configure --prefix=/usr/local/python
sudo make
sudo make install

五、创建符号链接


sudo ln -s /usr/local/python/bin/python3 /usr/bin/python
sudo ln -s /usr/local/python/bin/python3 /usr/bin/python3
sudo ln -s /usr/local/python/bin/pip3 /usr/bin/pip
sudo ln -s /usr/local/python/bin/pip3 /usr/bin/pip3