LoginSignup
10
4

More than 3 years have passed since last update.

あなたの macOS には何種類のPythonが入っていますか?私は401種類でしたが。

Last updated at Posted at 2020-03-09

あなたの Window 10 には何種類の Python が入っていますか?私は5種類でしたが。という記事が「いいね!」を集めていますが、大変残念なのは「結局どの Python を残したのか。」という段落があることです。この記述があたかも「5個もPythonがインストールされているのは異常」という印象を与えてしまっています。

真のPythonistaは、もしもの時の動作確認用に、全てのPythonをインストールしておくものです!!

というわけで、以下のコマンドで全てのPython(2020年3月9日現在で398種類)をインストールできます!この他にOS用のと、HomeBrewのPython2と3がインストールされているので401種類ですね!

pyenv install -l | tail -n +1 | cut -b 3- | xargs -n 1 pyenv install -f

なお、真面目な話をすると・・・

普通に開発業務をしていると、全プロジェクトが最新版Pythonを使っているわけではないので、サポート中のメジャーバージョン(過去3バージョン)ぐらいは、常に必要になります。マシンを支給された時に、先回りしてインストールしておいた方がいいです。

# 3.6.x 最新版
pyenv install -l | tail -n +1 | cut -b 3- | egrep '^3.6.\d+$' | tail -1 | xargs -n 1 pyenv install -f

# 3.7.x 最新版
pyenv install -l | tail -n +1 | cut -b 3- | egrep '^3.7.\d+$' | tail -1 | xargs -n 1 pyenv install -f

# 3.8.x 最新版
pyenv install -l | tail -n +1 | cut -b 3- | egrep '^3.8.\d+$' | tail -1 | xargs -n 1 pyenv install -f

3バージョンインストールした場合、1(OS) + 2(HomeBrew) + 3(pyenv) = 6種類になります。

10
4
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
10
4