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?

Python Install

Last updated at Posted at 2025-01-13

2025年1月13日現在でのPythonのインストール方法の紹介します。
現在のPythonの最新バージョンは3.13なので、そちらをインストールしていきます。

Windowsの場合

Microsoft Storeからのインストールがおすすめです。
Microsoft StorePython 3.13を検索、または、こちらのリンクからダウンロードしてください。

Mac, Ubuntu (Unix系) の場合

デフォルトでPythonがインストールされている場合が多いですが、開発者の場合、複数のバージョンをインストールしたい場合がありますので、Pyenvを使用してインストールするのがおすすめです。
ここからはターミナル (bash) を使って作業していきます。

Pyenvのインストール

$ git clone https://github.com/pyenv/pyenv.git ~/.pyenv

環境変数の設定

$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(pyenv init -)"' >> ~/.bashrc
$ source ~/.bashrc

Python 3.13のインストール

まずはpyenvでインストールできる環境一覧を見ます。

$ pyenv install -l

2.X.X3.X.XanacondaX.X.Xなど、色々と表示されるかと思いますが、今回はPython 3.13をインストールします。

$ pyenv install 3.13.1

インストールできましたら、以下で確認しましょう。

$pyenv versions

以下が表示されていれば、OKです。

3.13.1

環境の切り替え

デフォルトで3.13.1が使用できるように、環境を切り替えます。

$ pyenv global 3.13.1

以下のコマンドで環境が切り替わったか確認しましょう。

$ pyenv versions

アスタリスクのつく位置が変わっていれば、OKです。

* 3.13.1

Tips

特定のディレクトリ内では特定の環境を使用することもできます。その場合は、そのディレクトリに入り、pyenv local enviromentを実行しましょう。

$ cd directory
$ pyenv local enviroment

Pythonの動作確認

ターミナルを立ち上げて、pythonを実行してみましょう。

$ python

以下のように表示されていれば、インストール完了です。

Python 3.13.1 (main, Apr 19 2024, 16:48:06) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

終わりに

今回は、Pythonのインストール方法を紹介しました。
今後もPythonに関する記事を投稿していこうと思いますので、参考にしていただければと思います。

関連記事

  1. Python package install using pip
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?