LoginSignup
2
2

More than 3 years have passed since last update.

M1 Macのpython環境構築について

Last updated at Posted at 2021-04-15

はじめに

最近M1チップのMacの環境構築でよくエラーが出たりする問題をよく見かけます。
この記事では、M1チップのMac上で、pythonのよく使うライブラリであるmatplotlibのインストール方法について備忘録として残します。

テスト済み環境は以下です。
MacOS Big Sur 11.2.3
M1 MacBook Pro 13
python 3.8
pip 20.0.2

環境構築

pythonのライブラリ(ここでmatplotlib)をインストールする一般的な方法は

pip install matplotlib

あるいは

python3 -m pip install matplotlib

僕は最近この方法ではうまく行かなくて。。。
どうやらmatplotlibをインストールするときに、Pillowというライブラリも一緒にインストールされるので、そこでエラーを吐いちゃったみたいです。
僕のところで解決できた方法を以下に示す。

$ brew install libjpeg
$ git clone https://github.com/python-pillow/Pillow.git
$ cd Pillow
$ pip3 install . --no-binary :all: --no-use-pep517

Pillowをインストールするために、先に必要なlibjepgというライブラリをbrewでインストールします。
Pillowもlibjepgも描画用のライブラリらしいです。
それから、

$ git clone https://github.com/matplotlib/matplotlib.git
$ cd matplotlib
$ pip3 install . --no-binary :all:

でやってみてください。
ダメだった場合は、pip3をpython3 -m pipにかえてからやってみてください。

今回は以上です。

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