goo blog サービス終了のお知らせ 

coLinux日記

coLinuxはフリーソフトを種として、よろずのシステムとぞなれりける。

Raspberry Pi に Python 3.13.5 をインストールする。

2025-07-06 18:19:20 | Python
最近、用があって Python から離れていました。久しぶりに次回のアップデート時期を確認しようとしたら、最新バージョンが 3.13.5 にアップデートされていました。

https://www.python.org/downloads/release/python-3135/
によると、6月11日に公開されたようで、緊急のバグフィックス?版みたいです。

ここから======
これは Python 3.13 の 5 回目のメンテナンスリリースです。

Python 3.13はプログラミング言語Pythonの最新のメジャーリリースで、Python 3.12と比較して多くの新機能と最適化が含まれています。3.13.5 は 3.13 の 5 回目のメンテナンスリリースです。

3.13.5 は 3.13.4 リリースのいくつかの重要な問題を修正するための簡易リリースです:

 gh-135151: Windows での拡張モジュールのビルドに失敗しました。
 gh-135171: ジェネレーター式が作成時にTypeError(反復可能でないオブジェクトに対する反復処理時)を発生させなくなり、最初の使用まで遅延するようになりました。
 gh-135326: intライクなオブジェクト(numpy.int64など)をrandom.getrandbits()に渡すと失敗しました。以前はうまくいっていた。

その他のバグ修正(次のリリースまで待たねばならないようなもの)も含まれています。

DeepL.com(無料版)で翻訳しました。
======ここまで


というわけで、ジェネレータ式に関するものが気になるので、Raspberry Pi の Python3 も 3.13.5 に置き換えます。ソースは以下の通りです。

https://www.python.org/ftp/python/3.13.5/Python-3.13.5.tar.xz
https://www.python.org/ftp/python/3.13.5/Python-3.13.5.tar.xz.asc
MD5 Sum: dbaa8833aa736eddbb18a6a6ae0c10fa

ダウンロードとチェックを行います。

$ wget https://www.python.org/ftp/python/3.13.5/Python-3.13.5.tar.xz
--2025-07-05 14:09:12-- https://www.python.org/ftp/python/3.13.5/Python-3.13.5.tar.xz
Resolving www.python.org (www.python.org)... 2a04:4e42:400::223, 2a04:4e42:600::223, 2a04:4e42::223, ...
Connecting to www.python.org (www.python.org)|2a04:4e42:400::223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 22856016 (22M) [application/octet-stream]
Saving to: ‘Python-3.13.5.tar.xz’

Python-3.13.5.tar.x 100%[===================>] 21.80M 39.2MB/s in 0.6s

2025-07-05 14:09:13 (39.2 MB/s) - ‘Python-3.13.5.tar.xz’ saved [22856016/22856016]

$

$ wget https://www.python.org/ftp/python/3.13.5/Python-3.13.5.tar.xz.asc
--2025-07-05 14:11:02-- https://www.python.org/ftp/python/3.13.5/Python-3.13.5.tar.xz.asc
Resolving www.python.org (www.python.org)... 2a04:4e42:600::223, 2a04:4e42::223, 2a04:4e42:200::223, ...
Connecting to www.python.org (www.python.org)|2a04:4e42:600::223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 963 [application/octet-stream]
Saving to: ‘Python-3.13.5.tar.xz.asc’

Python-3.13.5.tar.x 100%[===================>] 963 --.-KB/s in 0s

2025-07-05 14:11:02 (15.8 MB/s) - ‘Python-3.13.5.tar.xz.asc’ saved [963/963]

$

$ gpg --verify Python-3.13.5.tar.xz.asc
gpg: assuming signed data in 'Python-3.13.5.tar.xz'
gpg: Signature made Wed 11 Jun 2025 18:45:54 BST
gpg: using RSA key 7169605F62C751356D054A26A821E680E5FA6305
gpg: Good signature from "Thomas Wouters <thomas@python.org>" [unknown]
gpg: aka "Thomas Wouters <thomas@xs4all.nl>" [unknown]
gpg: aka "Thomas Wouters <twouters@google.com>" [unknown]
gpg: aka "Thomas Wouters <thomas.wouters.prive@gmail.com>" [unknown]
gpg: aka "Thomas Wouters <thomaswout@gmail.com>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7169 605F 62C7 5135 6D05 4A26 A821 E680 E5FA 6305
$

$ md5sum Python-3.13.5.tar.xz; echo dbaa8833aa736e
ddbb18a6a6ae0c10fa
dbaa8833aa736eddbb18a6a6ae0c10fa Python-3.13.5.tar.xz
dbaa8833aa736eddbb18a6a6ae0c10fa
$

ビルドの前に、Python3 のための環境設定(PATH と LD_LIBRARY_PATH設定)をおこないます。
$ source ~/python3.sh
$ python3 --version
Python 3.13.4
$

さっそくインストールします。
$ tar xvf Python-3.13.5.tar.xz

$ cd Python-3.13.5

$ ./configure --prefix=/usr/local/python --with-readline --enable-shared --enable-optimizations
checking build system type... aarch64-unknown-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
checking for Python interpreter freezing... ./_bootstrap_python
checking for python3.13... python3.13
checking Python for regen version... Python 3.13.4
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking MACHDEP... "linux"
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking for --with-app-store-compliance... not patching for app store compliance
.........................................
configure: creating ./config.status
config.status: creating Makefile.pre
config.status: creating Misc/python.pc
config.status: creating Misc/python-embed.pc
config.status: creating Misc/python-config.sh
config.status: creating Modules/Setup.bootstrap
config.status: creating Modules/Setup.stdlib
config.status: creating Modules/ld_so_aix
config.status: creating pyconfig.h
configure: creating Modules/Setup.local
configure: creating Makefile
$

よく見ると、5行目の出力で今のPython3のバージョンをチェックしていますね。

$ time make
Running code to generate profile data (this can take a while):
# First, we need to create a clean build with profile generation
# enabled.
make profile-gen-stamp
...............................................
The necessary bits to build these optional modules were not found:
_dbm
To find the necessary bits, look in configure.ac and config.log.

Checked 112 modules (33 built-in, 77 shared, 1 n/a on linux-aarch64, 0 disabled, 1 missing, 0 failed on import)
make[1]: Leaving directory '/home/espiya/src/Python-3.13.5'

real 51m23.889s
user 48m38.787s
sys 1m36.611s

$

$ su
# make install

...............................................
Looking in links: /tmp/tmpfljb8xvi
Requirement already satisfied: pip in /usr/local/python/lib/python3.13/site-packages (25.1.1)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
# exit
$
$ which python3 pip3
/usr/local/python/bin/python3
/usr/local/python/bin/pip3
$ python3
Python 3.13.5 (main, Jul 5 2025, 15:17:14) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
$ pip3 -V
pip 25.1.1 from /home/espiya/.local/lib/python3.13/site-packages/pip (python 3.13)
$


無事にインストールできました。今後はこのバージョンの Python3 を利用します。

というわけで、次回の8月の定期アップデートはバージョンが一つずれて 3.13.6 になるようです。

コメント    この記事についてブログを書く
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする
« Raspberry Pi に Python 3.13... | トップ | Raspberry Pi に Python 3.13... »
最新の画像もっと見る

コメントを投稿

サービス終了に伴い、10月1日にコメント投稿機能を終了させていただく予定です。

Python」カテゴリの最新記事