Memo of python + numpy/scipy/pandas/matplotlib/jupyterlab environment construction on M1 macOS (as of 2020/12/24)

I want to do data science with arm64 native python and numpy/scipy/matplotlib, Jupyter-lab etc. on M1 macOS.

At present, if you try to install in the same way as for x86, M1 (arm64) will not compile due to moss etc. (Installed via pip or macports)

For example, there are issues such as altivec (everyone knows!) The compile flag is not supported by clang and numpy cannot be built.

https://github.com/numpy/numpy/issues/17807

It will be resolved someday, but it's a pain to wait. Building from source is more annoying.

You want to set up an Arm64 native data science environment easily and easily.

miniforge

Apple Silicon, run Scikit-Learn and TensorFlow on the new Macs M1 Run Machine Learning tools natively compiled for Apple Silicon https://towardsdatascience.com/new-apple-silicon-m1-macbook-air-the-dream-laptop-for-machine-learning-engineers-a1590fbd170f

As confirmed in, I use miniforge. It seems that the Arm64 version is originally packaged and maintained for Raspberry Pi etc., so it works fine on M1 as well.

https://github.com/conda-forge/miniforge

Use the arm64 version of the osx installer.

After that, you can use it as a normal (mini) conda.

conda create -n myenv python=3.9
conda activate myenv

Enter the environment as such,

conda install numpy

You can install arm64 as numpy!

Screen Shot 2020-12-16 at 3.36.53.png

Voila! :tada:

It takes a little time to start up at first, but it's taking a long time because it's not Rosetta2 but something else ... shouldn't it?

matplotlib

It worked without any problems.

https://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html

Let's run a script that uses numpy/scipy/matplotlib with reference to.

import numpy as np
from scipy.interpolate import interp1d
x = np.linspace(0, 10, num=11, endpoint=True)
y = np.cos(-x**2/9.0)
f = interp1d(x, y)
f2 = interp1d(x, y, kind='cubic')

xnew = np.linspace(0, 10, num=41, endpoint=True)
import matplotlib.pyplot as plt
plt.plot(x, y, 'o', xnew, f(xnew), '-', xnew, f2(xnew), '--')
plt.legend(['data', 'linear', 'cubic'], loc='best')
plt.show()

Screen Shot 2020-12-25 at 1.33.17.png

:tada:

Matplotlib backend error for Mac https://qiita.com/typecprint/items/0d4bea1251ab3f816303

Thank you.

It looks like the default MacOSX (native?) Backend in miniforge.

If necessary, refer to the link above and edit the matplotlibrc file to change the backend.

You may also try skipping the screen on the net such as WebAgg.

Jupyter-lab

https://forum.pine64.org/showthread.php?tid=10299

As you can see, miniforge seems to be recommended in Arm64 environment, and you can install it as it is with conda of miniforge as well!

$ conda activate myenv
$ conda install jupyterlab

All you have to do is start it with jupyter-lab normally!

Screen Shot 2020-12-25 at 2.00.42.png

Ultra super cooooooooooooool!!!!!! :tada:

Things that don't work

It will be macports, but it could not be installed because ffmpeg does not support arm64 for libvpx.

If you want to make a video using ffmpeg, will it be x86-64 version for a while?

TODO

Recommended Posts

Memo of python + numpy/scipy/pandas/matplotlib/jupyterlab environment construction on M1 macOS (as of 2020/12/24)
Python environment construction memo on Mac
Python development environment construction on macOS
Environment construction of python3.8 on mac
[Memo] Construction of cygwin environment
[MEMO] [Development environment construction] Python
Environment construction of python2 & 3 (OSX)
Environment construction of python and opencv
Anaconda python environment construction on Windows 10
Environment construction memo of pyenv + conda
Python environment construction procedure memo using Docker on Windows10 Home
Memo of Linux environment construction using VirtualBox + Vagrant on Windows 10
Emacs Python development environment construction memo
Environment construction of "Tello_Video" on Ubuntu
OpenCV3 & Python3 environment construction on Ubuntu
Addition of local development environment on MacOS
Build a python environment on MacOS (Catallina)
Python3 + venv + VSCode + macOS development environment construction
Python and machine learning environment construction (macOS)
Python environment construction
Environment construction (python)
python environment construction
Python --Environment construction
Python environment construction
python environment construction
A memo of a tutorial on running python on heroku
[Note] Python environment construction on rental server "CORESERVER"
Installation of Python3 and Flask [Environment construction summary]
Poetry-virtualenv environment construction with python of centos-sclo-rh ~ Notes
My python environment memo
Unification of Python environment
ConoHa environment construction memo
homebrew python environment construction
Python development environment construction
python2.7 development environment construction
BigGorilla environment construction memo
Anaconda environment construction memo
Mac environment construction Python
Python environment construction @ Win7
Notes on creating a python development environment on macOS Catalina
Support for Python 2.7 runtime on AWS Lambda (as of 2020.1)
QGIS3 Python plugin development environment construction with VSCode (macOS)
[Python] Django environment construction (pyenv + pyenv-virtualenv + Anaconda) for macOS
Build a Python development environment using pyenv on MacOS
Python environment construction on Mac (pyenv, virtualenv, anaconda, ipython notebook)
OpenJTalk on Windows10 (Speak Japanese with Python from environment construction)
Build a python machine learning study environment on macOS sierra
Anaconda environment construction on CentOS7
Django development environment construction memo
Construction of Python local development environment Part 2 (pyenv-virtualenv, pip usage)
Python environment construction (Windows10 + Emacs)
CI environment construction ~ Python edition ~
Made python available on macOS
Python environment construction For Mac
Anaconda3 python environment construction procedure
Build Python environment on Windows
Handling of python on mac
Anaconda3 × Pycharm environment construction memo
Python3 environment construction (for beginners)
How to develop in a virtual environment of Python [Memo]
Python environment construction and TensorFlow