0
0

More than 1 year has passed since last update.

Pythonをインストール

Last updated at Posted at 2021-09-21

1. Homebrewのインストール



ターミナルを開いて以下のコマンドを実行する

。

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



2. pyenvのインストール


以下のコマンドを実行

する。

$ brew install pyenv



3. pyenvの設定


以下のコマンドを実行


 $ echo $SHELL



・実行結果が 
/bin/bash の場合、以下4つのコマンドを実行

する。

$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile


$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile


$ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile


$ source ~/.bash_profile




・実行結果が /bin/zsh の場合、以下4つのコマンドを実行

する。

$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc


$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc


$ echo 'eval "$(pyenv init -)"' >> ~/.zshrc


$ source ~/.zshrc



4. Pythonのインストール

以下のコマンドでPythonをインストールします。


pyenv install [インストールしたいPythonのバージョン]

以下のコマンドでインストールできるPythonのバージョンが確認できます。


pyenv install --list



以下のコマンドを実行してインストールしたPythonのバージョンが表示していれば完了です。


python —version


参考文献

https://prog-8.com/docs/python-env
https://qiita.com/zaburo/items/29fe23c1ceb6056109fd
https://qiita.com/koooooo/items/b21d87ffe2b56d0c589b

0
0
1

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