LoginSignup
0
1

More than 1 year has passed since last update.

Apple M1環境のrosettaなしでpandas,numpy,Scikit-learn, matplotlibの使用。

Last updated at Posted at 2021-05-17

最近Apple M1環境でデーター分析を習おうと思ってpython3.9をインストールして以下のライブラリを設置しましたがうまくいきませんでした。

  • pandas
  • numpy
  • Scikit-learn
  • matplotlib

グーグル神様に聞いてもらいましたが何個の方法が相次いだのでここに整理しておきます。

1. Rosetta環境でpythonを実行する方法

Apple M1のarm64の確認方法は以下のようです。

>uname -m
arm64

これをarchコマンドを用いてx86で変更します。

>arch -x86_64 zsh
>uname -m
x86_64

こうすれば以前のApple intelヴァージョンのようにpip installを使えます。

でもここには何個の短所があるので…

  • Rosettaの性能的な限界
  • 実行するたびにarchで変更する不便さ

なのでライブラリーごと各個撃破を決定ました。

2. ライブラリーごとの各個撃破

まずbrew installでインストールできるのは以下のようです。

  • numpy
  • scipy

pandasとscikit-learnはBigSurのblasライブラリーが合わないから発生する問題です。

これはbrewでopenblasをインストールしこれを用いながらpandasとscikit-learnを設置します。

>brew install openblas

>OPENBLAS="$(brew --prefix openblas)" pip3 install pandas
>OPENBLAS="$(brew --prefix openblas)" pip3 install sklearn

ちょっと時間がかかるけど結局インストールができます。

matplotlibもpipではインストールができないんです。これはBigSurでlibjpegライブラリーがないからです。これは以下のコマンドラインで解決。

>brew install libjpeg

>pip3 install matplotlib

これでpandasからmatplotlibまでrosetta依存なしでインストール完了です。

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