LoginSignup
0
0

More than 3 years have passed since last update.

python のインストール手順

Posted at

python のインストール手順

 MacにPythonの3系をインストールするのに、ハマったのでメモ

phythonのインストール

こちらのHomebrew + pyenvを使用した手順でインストールを行う
Homebrewとpyenvのインストールは略

ターミナルで下記コマンドを実行して、
最初にインストール可能なヴァージョンの確認

$ pyenv install --list

実行結果

Available versions:
  2.1.3
  2.2.3
  2.3.7
  2.4.0
  2.4.1
  2.4.2
  2.4.3
  2.4.4
  2.4.5
 ・
 ・
 ・

今回は3.9.4をインストールしたいので、下記を実行

$ pyenv install 3.9.4

成功↓

python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.9.4.tar.xz...
-> https://www.python.org/ftp/python/3.9.4/Python-3.9.4.tar.xz
Installing Python-3.9.4...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

Installed Python-3.9.4 to {path}

念の為、versionsの確認

$ pyenv versions

↓のようにインストールしたversionsが出ていればよい

  system
* 3.9.4 (set by {path})

インストールしただけでは、適用されないので、
下記コマンドを実行

$ pyenv global 3.9.4

実行したら、versionの確認

$ python --version  

↓mac標準のversionsのまま。なんでさ

Python 2.7.16

https://github.com/pyenv/pyenv#homebrew-on-mac-os-x
によると以下手順が必要とのこと

$ pyenv init  

↓実行結果の指示通り、.zshrcに"eval "$(pyenv init -)"を追記または、
記載していることを確認

# Load pyenv automatically by appending
# the following to ~/.zshrc:

eval "$(pyenv init -)"

下記、実行してversion確認

$ source ~/.bash_profile
$ python -V

↓インストールしたものが適用されました。

Python 3.9.4

これで、phytonのインストールは完了

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