0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

raspiのpythonを3.8にする

Last updated at Posted at 2024-07-03

importlib.metadata
が3.8から使えるということでraspiのバージョンを上げました。

3.7.3 -> 3.8

Raspberry Pi OS (Raspbian Buster)は、デフォルトでPython 3.8は提供されていない(?)
Python 3.8を手動でインストールする。

$ sudo apt update
$ sudo apt install -y \
    build-essential \
    libssl-dev \
    zlib1g-dev \
    libncurses5-dev \
    libncursesw5-dev \
    libreadline-dev \
    libsqlite3-dev \
    libgdbm-dev \
    libdb5.3-dev \
    libbz2-dev \
    libexpat1-dev \
    liblzma-dev \
    tk-dev \
    libffi-dev \
    libgdbm-compat-dev \
    wget


$ cd /usr/src
$ sudo wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
$ sudo tar xzf Python-3.8.0.tgz

$ python3.8 --version
->
Python 3.8.0

めんどくさいのでシンボリックリンクを作成

$ sudo ln -sf /usr/local/bin/python3.8 /usr/bin/python
$ ls -l /usr/local/bin/python3.8 /usr/bin/python
lrwxrwxrwx 1 root root       24  7月  3 21:39 /usr/bin/python -> /usr/local/bin/python3.8
-rwxr-xr-x 1 root root 15283956  7月  3 20:43 /usr/local/bin/python3.8

$ python --version
Python 3.8.0

$ cd [ソースがある場所へ]
$ python -m venv .venv
$ source .venv/bin/activate

$ pip install gpiozero

->
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting gpiozero
  Using cached https://files.pythonhosted.org/packages/b3/b5/64b461f496134218886a18cbfa40def2b9b1c152c10c71efa992f07952e0/gpiozero-2.0-py3-none-any.whl
Collecting colorzero (from gpiozero)
  Using cached https://files.pythonhosted.org/packages/7e/a6/ddd0f130e44a7593ac6c55aa93f6e256d2270fd88e9d1b64ab7f22ab8fde/colorzero-2.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools in /home/pi/.venv/lib/python3.7/site-packages (from colorzero->gpiozero) (40.8.0)
Installing collected packages: colorzero, gpiozero
Successfully installed colorzero-2.0 gpiozero-2.0

成功

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?