Raspberry Pi 安装 Python3 和 pip

凌顺实验室(lingshunlab.com)分享在RaspberryPi(树莓派)中如何安装Python和pip,还有遇到的一些常见问题解决方法。

安装Python3

sudo apt-get install python3

一般情况下,Raspberry Pi的系统会预装Python

安装pip

pip for python2

sudo apt-get install python-pip

pip for python3

sudo apt-get install python3-pip

image-20210914114602752

验证安装是否成功

pip3 --version

image-20210914114832723

更新pip

更新系统已安装的程序或软件包

sudo apt-get update
sudo apt-get upgrade

更新升级pip

python -m pip install --upgrade pip

常见问题

提示 Cache entry deserialization failed, entry ignored

如果遇到以下情况

Cache entry deserialization failed, entry ignored

  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: TLSV1_ALERT_ACCESS_DENIED] tlsv1 alert access denied (_ssl.c:777)'),)': /simple/sklearn/

  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: TLSV1_ALERT_ACCESS_DENIED] tlsv1 alert access denied (_ssl.c:777)'),)': /simple/sklearn/

  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: TLSV1_ALERT_ACCESS_DENIED] tlsv1 alert access denied (_ssl.c:777)'),)': /simple/sklearn/

  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: TLSV1_ALERT_ACCESS_DENIED] tlsv1 alert access denied (_ssl.c:777)'),)': /simple/sklearn/

  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: TLSV1_ALERT_ACCESS_DENIED] tlsv1 alert access denied (_ssl.c:777)'),)': /simple/sklearn/

尝试以下方法,有助解决问题: 1,改变网络 2,清空pip的缓存来修复它,输入以下命令

rm -rf ~/.cache/pip