一、更新树莓派系统固件资源
sudo apt-get update
sudo apt-get upgrade
二、安装软件
python3.6.6 参考
# 安装编译所需依赖包
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
# 安装SSL依赖
sudo apt-get install libssl-dev
# 到官网下载Python3.6.6: https://www.python.org/downloads/source/
wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tar.xz
# 解压
tar xf Python-3.6.6.tar.xz
# 进入目录
cd Python-3.6.6
# 开始编译(时间漫长,需要等待,建议用&&把三句连在一起执行)
sudo ./configure
sudo make
sudo make install
# 升级pip
sudo python3.6 -m pip install --upgrade pip
为了方便输入命令(如python或python3),我们还要创建一个链接:
# 先查询本机刚装好的Python3.6的位置
$ which python3.6
/usr/local/bin/python3.6
# 把这个python3.6的链接放到/usr/bin中,可供直接输入命令
$ sudo ln -s /usr/local/bin/python3.6 /usr/bin/python
# 如果不能创建链接,遇到有重复,则查询`python`情况,然后互相变下名字解决
$ python -V
Python 2.7.9
$ sudo mv /usr/bin/python /usr/bin/python2
$ sudo ln -s /usr/local/bin/python3.6 /usr/bin/python