概要
リモートサーバのUbuntu22.04にPython3.10.6をインストールします。最初からインストールされているPythonはOS用なので、別のPythonをインストールして使うのが一般的とのことでした。Ubuntu22.04にもともとインストールされていたPythonは3.10.4でした。作業PCはWindows10 Proです。
記事を参考にさせていただきました。
Ubuntu環境のPython
デフォルトでインストールされているPythonを使うのはヤバイ
手順1 ビルドツール・ライブラリのインストール
UbuntuにPythonをインストールするにはビルドする必要があるらしいので、ビルドツールをインストールします。
$ sudo apt update
$ sudo apt install build-essential libbz2-dev libdb-dev \
libreadline-dev libffi-dev libgdbm-dev liblzma-dev \
libncursesw5-dev libsqlite3-dev libssl-dev zlib1g-dev uuid-dev
GUIなしのWebサーバとして動かしたいのでtk-devは消しました。
手順2 Python3.10.6をダウンロード
ここからダウンロードします。
手順3 リモートサーバに送る
作業PCにダウンロードしたPythonを、teratermにドラッグアンドドロップして、リモートのUbuntuのホームディレクトリに送ります。
ちゃんと送られてました。
手順4 Pythonを解凍してビルドしてインストール
$ tar xJf Python-3.10.6.tar.xz
$ cd Python-3.10.6
Python-3.10.6$ ./configure
Python-3.10.6$ make
Python-3.10.6$ sudo make install
手順5 再起動と確認と後片付け
Python-3.10.6$ sudo shutdown -r now
$ python3 --version
$ sudo rm -rf Python-3.10.6
$ sudo rm -rf Python-3.10.6.tar.xz