1
3

More than 1 year has passed since last update.

M1 Macにデータ分析環境を作る

Last updated at Posted at 2021-12-19

はじめに

M1 Mac M1はCPUのアーキテクチャーがarm64ベースということで、X86ではありません。

一般的にはIntelを代表とするX86アーキテクチャーを前提で作られたパッケージが多いため、arm64にインストールできないということもよくあります。

ここではM1 Macにデータ解析基盤を作ることを目的とし、その方法を以下に示します。

M1 Macへの構築方法

pyenvのインストール

最初にpyenvをインストールしてください。インストール方法は、pyenvのgithubを参考にしてください。

miniforge3-4.10.1-5 のインストール

つぎにArmアーキテクチャーに対応済みのminiforgeをインストールします。

command
pyenv install miniforge3-4.10.1-5
pyenv global miniforge3-4.10.1-5
pyenv versions
command
python -VV
Python 3.9.2 | packaged by conda-forge | (default, Feb 21 2021, 05:00:30) 
[Clang 11.0.1 ]

conda環境の構築

なんでcondaを使わないといけないかは、miniforge conda でググってください。

command
ENV_NAME="myenv"
conda create --name ${ENV_NAME} python=3.9.6
conda activate ${ENV_NAME}

以下を確認します。

  • pythonが 3.9.6 であること
  • condaの環境が上記で定義した ${ENV_NAME} になっていること
  • pyenvからも ${ENV_NAME}の環境が見えること
確認
python -VV
conda info -e
pyenv versions

必要パッケージのインストール

順番変えれば、numpyとか自動的に入りますが、以下の順番は個人の好みです。

command
conda install -c conda-forge conda-forge::numpy -y
conda install -c conda-forge conda-forge::pandas -y
conda install -c conda-forge conda-forge::matplotlib -y
conda install -c conda-forge conda-forge::seaborn -y
conda install -c conda-forge conda-forge::lightgbm -y
conda install -c conda-forge conda-forge::jupyterlab -y
conda install -c conda-forge conda-forge::geopandas -y
conda install -c conda-forge conda-forge::xgboost -y
conda install -c conda-forge conda-forge::nltk -y
conda install -c conda-forge conda-forge::opencv -y
conda install -c conda-forge conda-forge::ipywidgets -y
conda install -c conda-forge conda-forge::IProgress -y
conda install -c conda-forge conda-forge::lime -y
conda install -c conda-forge conda-forge::lit-nlp -y
conda install -c conda-forge conda-forge::tfds-nightly -y
conda install -c apple tensorflow-deps

一部condaで入らないやつは、割り切ってpipでインストールします

command
pip install optuna
pip install tfds-nightly
pip install tensorflow-macos
pip install tensorflow-metal
pip install tensorflow_hub
pip install tensorflow_text
pip install pandas_profiling

tensorflowに関しては以下も参考

参考文献

1
3
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
1
3