0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【macOS】Homebrew経由で最新のPythonをインストール&パスを通す

0
Posted at

はじめに

macOSにて,Homebrew経由で最新のPythonのインストール&パスを通す方法です.
私がmacOSを初期化するたびに,「あれ?最新のPythonのパスってどうやって通したっけ?」となるので,ほぼ備忘録です.

手順

Homebrew インストール

Homebrewをインストールしていない場合はインストール

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

Homebrewのパス通し&確認

Homebrewのインストールが完了すると,

==> Next steps:

  • Run these commands in your terminal to add Homebrew to your PATH:
    echo >> /Users/[macの名前]/.zprofile
    echo 'eval "$(/opt/homebrew/bin/brew shellenv zsh)"' >> /Users/[macの名前]/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv zsh)"
  • Run brew help to get started
  • Further documentation:
    https://docs.brew.sh

のように案内がある(はず)なので,その通りに進めていく.

echo >> /Users/[macの名前]/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv zsh)"' >> /Users/[macの名前]/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv zsh)"

# 最後に確認
brew -v 

Python インストール

brew install python

Python バージョン確認

python3 --version

または

python --version

この時,最新のPythonでなかった場合はmacに元々入っているPythonが反応している.

その場合は,以下のようにしてパスを通す.

HomebrewのPythonバージョン確認

/opt/homebrew/bin/python3 --version
ここで,最新バージョンのPythonが表示されるはず.

Homebrewでインストールした最新のPythonのパスを追加

echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

バージョンの最終確認

python3 --version

または

python --version
0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?