Notebook

これは日々の作業を通して学んだことや毎日の生活で気づいたことをを記録しておく備忘録である。

HTML ファイル生成日時: 2025/07/30 08:17:51.269 (台灣標準時)

Google Colab で Python 3.12 を使う方法

Python は、常に変化し続けているので、そのバージョンによって以前に書い たプログラムが動かなかったりすることがあるでござる。なので、「このバー ジョンを使う」と決めておくとよいでござる。以前に Google Colab で Python 3.12 をインストールして、 Python 3.12 を使う方法を記録しておいたで ござる。

が、数日前から、以下の方法だと Python 3.12 がインストールされなくなっ てしまったでござる。


# Run this cell to install Python 3.12

!apt update
!apt upgrade
!apt install python3.12 python3.12-dev python3.12-distutils libpython3.12-dev
!update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1
!wget https://bootstrap.pypa.io/get-pip.py
!python3.12 get-pip.py

python3.12-distutils がインストールされていないようでござる。 OS のバー ジョンが上がって、 python3.12-distutils というパッケージがなくなったの でござろうか。


E: Unable to locate package python3.12-distutils
E: Couldn't find any package by glob 'python3.12-distutils'

Python 3.12 に関連するパッケージは、どんな名前になったのか確認してみた でござる。


Sorting... Done
Full Text Search... Done
idle-python3.12/jammy 3.12.8-1+jammy1 all
  IDE for Python (v3.12) using Tkinter

libpython3.12/jammy 3.12.8-1+jammy1 amd64
  Shared Python runtime library (version 3.12)

libpython3.12-dbg/jammy 3.12.8-1+jammy1 amd64
  Debug Build of the Python Interpreter (version 3.12)

libpython3.12-dev/jammy 3.12.8-1+jammy1 amd64
  Header files and a static library for Python (v3.12)

libpython3.12-stdlib/jammy 3.12.8-1+jammy1 amd64
  Interactive high-level object-oriented language (standard library, version 3.12)

libpython3.12-testsuite/jammy 3.12.8-1+jammy1 all
  Testsuite for the Python standard library (v3.12)

python3.12/jammy 3.12.8-1+jammy1 amd64
  Interactive high-level object-oriented language (version 3.12)

python3.12-dbg/jammy 3.12.8-1+jammy1 amd64
  Debug Build of the Python Interpreter (version 3.12)

python3.12-dev/jammy 3.12.8-1+jammy1 amd64
  Header files and a static library for Python (v3.12)

python3.12-examples/jammy 3.12.8-1+jammy1 all
  Examples for the Python language (v3.12)

python3.12-full/jammy 3.12.8-1+jammy1 amd64
  Python Interpreter with complete class library (version 3.12)

python3.12-gdbm/jammy 3.12.8-1+jammy1 amd64
  GNU dbm database support for Python (version 3.12)

python3.12-gdbm-dbg/jammy 3.12.8-1+jammy1 amd64
  GNU dbm database support for Python (version 3.12 debug extension)

python3.12-lib2to3/jammy 3.12.8-1+jammy1 all
  lib2to3 package for Python (version 3.12)

python3.12-tk/jammy 3.12.8-1+jammy1 amd64
  Tkinter - Writing Tk applications with Python (version 3.12)

python3.12-tk-dbg/jammy 3.12.8-1+jammy1 amd64
  Tkinter - Writing Tk applications with Python (version 3.12 debug extension)

python3.12-venv/jammy 3.12.8-1+jammy1 amd64
  Interactive high-level object-oriented language (pyvenv binary, version 3.12)

どうも python3.12-full をインストールしておけばよさそうでござる。以下 を試してみたでござる。


# Run this cell to install Python 3.12

!apt update
!apt upgrade
!apt install python3.12 python3.12-full python3.12-dev libpython3.12-dev
!update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1
!wget https://bootstrap.pypa.io/get-pip.py
!python3.12 get-pip.py

上のコマンドを実行した上で、 Python のバージョンを確認してみると、 3.12 になっていたでござる。


# Run this cell to check the version of Python interpreter and pip command

!python --version
!pip --version

Python 3.12.8
pip 24.3.1 from /usr/local/lib/python3.12/dist-packages/pip (python 3.12)

uname を実行してみたでござる。


!uname -srm

Linux 6.1.85+ x86_64

fig_202412/www_colab_python312_00.png
fig_202412/www_colab_python312_01.png
fig_202412/www_colab_python312_02.png
fig_202412/www_colab_python312_03.png
fig_202412/www_colab_python312_04.png
fig_202412/www_colab_python312_05.png
fig_202412/www_colab_python312_06.png


Frequently accessed files

  1. Misc___Taiwan/20240819_00.html
  2. Computer___TeX/20231107_00.html
  3. Misc___Taiwan/20240207_00.html
  4. Computer___Network/20230516_00.html
  5. Computer___NetBSD/20250301_01.html
  6. Computer___NetBSD/20230119_00.html
  7. Computer___NetBSD/20240805_03.html
  8. Food___Taiwan/20230609_06.html
  9. Food___Taiwan/20230608_04.html
  10. Computer___NetBSD/20250728_00.html
  11. Food___Taiwan/20220605_4.html
  12. Computer___TeX/20240410_00.html
  13. Misc___Taiwan/20250728_01.html
  14. Computer___Network/20230726_00.html
  15. Computer___NetBSD/20250409_00.html
  16. Computer___Python/20240101_00.html
  17. Computer___Hardware/20250319_00.html
  18. Misc___Taiwan/20220831_4.html
  19. Misc___Taiwan/20240903_01.html
  20. Food___Taiwan/20220811_9.html
  21. Computer___TeX/20230726_01.html
  22. Food___Taiwan/20230604_00.html
  23. Food___Taiwan/20230711_15.html
  24. Food___Cooking/20230625_03.html
  25. Travel___Taiwan/20230525_09.html
  26. Computer___FreeBSD/20240123_00.html
  27. Food___Cooking/20220821_5.html
  28. Food___Taiwan/20210216_1.html
  29. Food___Taiwan/20230622_10.html
  30. Food___Taiwan/20230724_00.html


HTML file generated by Kinoshita Daisuke.