pyenv
Pythonのバージョンを選択できるようにする
pyenv 2.0からパスの設定はpyenv init --pathになっているので注意
Raspberry Piでインストール
~/.bash_profileに設定を追加
code:~/.bash_profile
export LANG=ja_JP.UTF-8
export EDITOR=vi
# pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
. "$HOME/.profile" # .bashrcもここで読み込まれる
fi
~/.bashrcに以下を追加
code:~/.bashrc
eval "$(pyenv init -)"
インストール
code:console
. ~/.bash_profile
pyenv update
Pythonのコンパイルに必要なライブラリをインストール
libjpeg62-turbo-dev(Ubuntuで言うlibjpeg8-dev)はPILで必要
Bluetoothを使うならlibbluetooth-devも必要
code:console
sudo apt install make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \
libjpeg62-turbo-dev libbluetooth-dev
Pythonのインストール
code:console
$ pyenv versions # インストールされているPythonの一覧
* system (set by /home/pi/.pyenv/version)
$ pyenv install --list # インストールできるPythonの一覧
$ pyenv install 3.10.0
$ pyenv global 3.10.0
$ pyenv versions
system
* 3.10.0 (set by /home/pi/.pyenv/version)
$ python -m pip install --upgrade pip
コンパイル時間
reTerminal(Compute Module 4)
3.10.0で6分32秒くらい
code:console
saito@reterminal:~ $ time pyenv install 3.10.0
Downloading Python-3.10.0.tar.xz...
Installing Python-3.10.0...
patching file aclocal.m4
patching file configure
Hunk #5 succeeded at 10537 (offset -15 lines). Installed Python-3.10.0 to /home/saito/.pyenv/versions/3.10.0
real 6m32.760s
user 17m7.594s
sys 1m37.639s
Raspberry Pi 400 4GB
3.9.6で5分45秒くらい
code:console
pi@pi400jp:~ $ time pyenv install 3.9.6
Downloading Python-3.9.6.tar.xz...
Installing Python-3.9.6...
Installed Python-3.9.6 to /home/pi/.pyenv/versions/3.9.6
real 5m44.816s
user 14m57.681s
sys 1m34.193s
pi@pi400jp:~ $
Raspberry Pi 4B 8GB
3.8.5で5分半
code:console
$ time pyenv install 3.8.5
Downloading Python-3.8.5.tar.xz...
Installing Python-3.8.5...
Installed Python-3.8.5 to /home/saito/.pyenv/versions/3.8.5
real 5m34.824s
user 14m17.773s
sys 1m26.137s
Raspberry Pi Zero WH
3.8.2で1時間20分くらい
code:console
$ time pyenv install 3.8.2
Downloading Python-3.8.2.tar.xz...
Installing Python-3.8.2...
Installed Python-3.8.2 to /home/pi/.pyenv/versions/3.8.2
real 79m6.508s
user 71m11.613s
sys 4m19.655s