6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

MacでPythonをインストールする方法

Posted at

MacにPythonを新しく導入する際の分かりやすい手順をご紹介します。

まずは準備

ご存知かもしれませんが、Macには標準でPythonがインストールされております。ただし、古いバージョンであることが多いので、最新のPythonを使うためには改めてインストールが必要です。

方法1: 公式サイトからのダウンロード

  1. Pythonの公式サイトにアクセスしてください。
  2. 「Python 3.x.xのダウンロード」をクリックし(x.xはバージョン番号)、ファイルをダウンロードします。
  3. ダウンロードした .pkg ファイルを開いて、画面に表示される指示に従いインストールを進めてください。

公式サイトからのダウンロードは、最も直接的なインストール方法です。

方法2: Homebrewを活用する

HomebrewとはMac用のパッケージ管理ツールで、コマンドラインから簡単に様々なソフトウェアをインストールできます。

初めに、Homebrewが既にインストールされているかを確認しましょう。ターミナルを開き、次のコマンドを入力してください。

brew -v

もしインストールされていない場合は、以下のコマンドで導入できます。

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

そして、Pythonをインストールするためには次のコマンドを実行します。

brew install python

これで最新のPythonがご利用いただけます。

方法3: pyenvでのバージョン管理

異なるバージョンのPythonを管理する必要がある場合は、pyenvが非常に便利です。

まずpyenvをインストールするには、以下のコマンドを利用します。

brew install pyenv

インストール後、お望みのPythonのバージョンをインストールしてください。

pyenv install 3.x.x
pyenv global 3.x.x

3.x.xの部分には、インストールしたいPythonのバージョン番号を入力してください。

インストールの確認

Pythonが正しくインストールされたかを確認するために、ターミナルで以下のコマンドを入力してください。

python --version

または

python3 --version

これでインストールされたPythonのバージョンが表示されます。

6
2
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
6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?