LoginSignup
1
1

More than 1 year has passed since last update.

RaspberryPi4BにPython3.10をインストールした

Posted at

やること

RaspberryPiにPython3.10をインストールして使えるようにする。

背景

WSL2で作ったPythonスクリプトをRaspberry Pi 4Bで実行しようとしたらエラーがでた。
よくよく観察すると、Pythonのバージョンが古いことが原因っぽい。
Pythonのバージョンを見てみたら、3.7xxとかだった。

RaspberryPi のバージョンとか

HW: Raspberry Pi4B
OS: RaspberryPiOS(64bit)

$ uname -a
Linux raspberrypi 5.10.17-v8+ #1421 SMP PREEMPT Thu May 27 14:01:37 BST 2021 aarch64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 10 (buster)
Release:	10
Codename:	buster
$ cat /proc/cpuinfo
processor	: 0
:(省略)
Hardware	: BCM2835
Revision	: c03112
Serial		: xxxxxxxxxxxxxxxx
Model		: Raspberry Pi 4 Model B Rev 1.2

解決策

Googleで検索したら、
こちらのサイトに記述があった。

やりかた

次のコマンドを実行するだけ。たぶんコマンド末尾の"3.10.0"を入れ替えると、そのバージョンがインストールされるんだと思う。

wget -qO - https://raw.githubusercontent.com/tvdsluijs/sh-python-installer/main/python.sh | sudo bash -s 3.10.0

※コマンドは上記のWEBサイトから抜粋

結果

コマンドを投入してから完了まで30分くらいかかった。
指定したバージョンがインストールできた。

$ python --version
Python 3.10.0

作ったpythonスクリプトも無事動いた。

以上

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1