LoginSignup
9
7

More than 5 years have passed since last update.

minicondaでスマートに環境構築 for Mac

Posted at

概要

さあ、機械学習をはじめよう!といった場合に、まずはじめにつまづきやすいポイントは開発環境の構築でしょう。
pyenvとanacondaをインストールして環境構築する記事が目立ちますが、正直なところあまりお勧めできません。
・pyenvでPython2系と3系を使い分ける必要は皆無(2系は2020年にサポート終了するので、さっさと3系に移行しましょう)
・Anacondaは機械学習では使わないライブラリが多いわりに、必要とするライブラリは結局pipでインストールするので、理にかなってない。

...と、pyenv+Anacondaのデメリット書き出すとキリがありません。
てか、機械学習の開発現場からいらないライブラリが多すぎる!という不満が多くて、
必要最小限の機能だけ詰め込んだMinicondaを作ったんだろうねってことは容易に想像できちゃいます。。

というわけで、Minicondaでシンプルに開発環境を構築していきましょう^^

マニュアルを読んでインストールしてみよう!

かなり当たり前のことですが、公式マニュアルをしっかり読んでから、インストールしましょう。
Minicondaに限らず、なんでもそうですが、他のブログや記事の通りに作業する前に、出典元である公式ドキュメントを理解してから作業に取り掛かりましょう。基本です。
マニュアルは英語なので、毛嫌いする人もいますが、機械学習の分野で活躍していくためには、英語は必須スキルです。
英語苦手な方もこれを機にトライしましょう。専門用語さえ理解できていれば、英語は難しくありません。

Installation — Conda documentation

要点を書きながら、マニュアル通りにインストールします。

System requirements
32- or 64-bit computer.
For Miniconda—400 MB disk space.
For Anaconda—Minimum 3 GB disk space to download and install.
Windows, macOS or Linux.
Python 2.7, 3.4, 3.5 or 3.6.
pycosat.
PyYaml.
Requests.

システム要件では、Anacondaは3GB必要としますが、Minicondaは400MBのディスク容量で事足りるみたいですね。

Installing conda on a system that has other Python installations or packages

You do not need to uninstall other Python installations or packages in order to use conda. Even if you already have a system Python, another Python installation from a source such as the macOS Homebrew package manager and globally installed packages from pip such as pandas and NumPy, you do not need to uninstall, remove, or change any of them before using conda.

Install Anaconda or Miniconda normally, and let the installer add the conda installation of Python to your PATH environment variable. There is no need to set the PYTHONPATH environment variable.

もうすでにインストールしたPythonパッケージをアンインストールする必要はありません。PYTHONPATHを通す必要もなし。

お次は、Minicondaインストーラのページ
Miniconda — Conda

自分はMacOSなので、MacOSのインストーラをダウンロードします。もちろんPython3系。
ターミナルを開いて、作業領域でインストーラを実行。早速インストールします。

$ bash Miniconda3-latest-MacOSX-x86_64.sh

Do you accept the license terms? [yes|no]

途中で、ライセンス許可が求められるので、yesを選択します。

Do you wish the installer to prepend the Miniconda3 install location
to PATH in your /Users/hamamac/.bash_profile ? [yes|no]

.bash_profileにMiniconda3のパスを通してもいいか聞かれます。
yesを選択してOKです。既存のbash_profileはバックアップされます。

For this change to become active, you have to open a new terminal.
Thank you for installing Miniconda3!

新しく、ターミナルを開いて、確認してみましょう。

$ conda -V
conda 4.5.4

とっても簡単でしたね。
記事にする必要がないぐらいシンプルでしたが、
Pythonの開発環境構築系の記事は複雑なやり方している人が多いと思って書きました。
環境構築はシンプルであるべきです。シンプルイズベスト。
では、良きAIライフを!

9
7
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
9
7