1
0

More than 1 year has passed since last update.

Ubuntu22.04 Python3.10.6をインストールする

Last updated at Posted at 2022-08-04

概要

リモートサーバの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をダウンロード

ここからダウンロードします。
image.png

手順3 リモートサーバに送る

作業PCにダウンロードしたPythonを、teratermにドラッグアンドドロップして、リモートのUbuntuのホームディレクトリに送ります。
image.png
ちゃんと送られてました。
image.png

手順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
1
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
1
0