Macbook Air with M1 is here! Quickly create a Python computing environment

Introduction

On December 28, 2020, the Macbook Air with M1 arrived. Since it is an M1 and a hobby Mac, I decided to improve the usage environment without using Rosetta 2.

First, install Google Chrome (browser) and CotEditor (text editor) that support M1 (Apple Silicon). Next is the installation of Python in question. I tried two methods as the method I checked in advance.

As a result, using Miniforge3 made it relatively easy to create the equivalent of what I used to use on my iMac. The iMac python environment is created with pyenv, but I haven't used it to switch between multiple versions. When pip and pyenv start running on M1, I'll start over there.

(Reference) I tried to install BasicTeX but gave up (2021.01.01)

TeX seems to be compatible with Apple silicon, so I tried installing BasicTeX.

I abandoned the installation of both of the above because I was asked to install Rosetta 2 on the way. It does not mean "cannot be installed", but it means "cannot be installed" because it is contrary to this idea because it cannot be installed without installing Rosetta 2.

Python installation (Homebrew)

The first is to install Python from Homebrew. I tried according to the following.

https://dev.classmethod.jp/articles/make-3-9-as-python-default-on-m1-mac/

I was able to install Homebew and Python 3.9 smoothly. But numpy, matplotlib doesn't work with pip,

I tried putting numpy from Homebrew, but numpy is OK, but it doesn't follow, such as installing matplotlib with pip. In addition, it seems that GCC (gfortran) and openblas will be installed at the same time as numpy. I uninstalled numpy and openblas, but got gfortran. The version confirmation result of gfortran is as follows.

(base) % gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc/10.2.0/libexec/gcc/aarch64-apple-darwin20/10.2.1/lto-wrapper
Target: aarch64-apple-darwin20
Configured with: ../configure --build=aarch64-apple-darwin20 --prefix=/opt/homebrew/Cellar/gcc/10.2.0 --libdir=/opt/homebrew/Cellar/gcc/10.2.0/lib/gcc/10 --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-10 --with-gmp=/opt/homebrew/opt/gmp --with-mpfr=/opt/homebrew/opt/mpfr --with-mpc=/opt/homebrew/opt/libmpc --with-isl=/opt/homebrew/opt/isl --with-system-zlib --with-pkgversion='Homebrew GCC 10.2.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk SED=/usr/bin/sed
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.1 20201220 (Homebrew GCC 10.2.0) 
(base) % 

(Conclusion) Python itself and numpy are lonely. Failure to build a Python computing environment.

Python installation (Miniforge3)

The second is done as written, referring to the following site.

Get the script for arm64 (Apple Silicon) from https://github.com/conda-forge/miniforge and execute it.

bash Miniforge3-MacOSX-arm64.sh

After that, create an environment called `myenv` and install what you want steadily. This `` `myenv``` can be any name you like. I followed the example of my predecessor and gave it the same name.

conda create -n myenv python=3.9
conda activate myenv

conda install numpy
conda install matplotlib
conda install sciPy
conda install pandas
conda install scikit-learn
conda install openpyxl
conda install jupyterlab

myenvIs activated and put inimportCheck if you can. .. .. OK. of coursejupyter notebookAlso works.

(base) % conda activate myenv
(myenv) % python
Python 3.9.1 | packaged by conda-forge | (default, Dec 21 2020, 22:08:11) 
[Clang 11.0.0 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import matplotlib
>>> import scipy
>>> import pandas
>>> import sklearn
>>> import openpyxl
>>> quit()
(myenv) % 

openpyxlIs put, but ms-There is no problem even if there is no office. You can read the excel file created in the past, and you can check the contents of the output in excel format with the numbers that come standard with mac.

That said, I bought Microsoft 365

I bought Microsoft 365 on January 14th. At this point, it is compatible with Apple silicon and installed without any problems. The behavior is also stable.

I installed it with jupyterlab, but I'm using jupyter notebook

Here is a photo showing that the Jupyter notebook is running. Since it is a demo, I tried to display the screen of Jupyter notebook on iPad Air with Sidecar.

IMG_0257.jpeg

(Conclusion) At this point (December 29, 2020), it is easy to use "Miniforge 3" to quickly create a Python computing environment. At least you can use numpy, Matplotlib, scipy, pandas, scikit-learn, openpyxl, Jupyter notebook. However, you need to activate the conda environment to use it.

that's all

Recommended Posts

Macbook Air with M1 is here! Quickly create a Python computing environment
Create a virtual environment with Python!
[Python] Create a virtual environment with Anaconda
Create a virtual environment with conda in Python
Create a python3 build environment with Sublime Text3
Create a Python environment
Quickly build a Python Django environment with IntelliJ
Create a simple Python development environment with VSCode & Docker Desktop
[Python] What is a with statement?
Create a Python environment on Mac (2017/4)
Building a virtual environment with Python 3
Create a python environment on centos
Create a Python execution environment for Windows with VScode + Remote WSL
Try to create a python environment with Visual Studio Code & WSL
Create a C ++ and Python execution environment with WSL2 + Docker + VSCode
Create a simple Python development environment with VS Code and Docker
Create a USB boot Ubuntu with a Python environment for data analysis
[Pyenv] Building a python environment with ubuntu 16.04
Create a Python function decorator with Class
Building a Python3 environment with Amazon Linux2
Build a blockchain with Python ① Create a class
Create a dummy image with Python + PIL.
Create a python environment on your Mac
Let's create a virtual environment for Python
Let's create a free group with Python
Quickly create an excel file with Python #python
Building a Python 3.6 environment with Windows + PowerShell
[Python] Create a Batch environment using AWS-CDK
Create Python + uWSGI + Nginx environment with Docker
Create a virtual environment with Python_Mac version
Build a python virtual environment with pyenv
Build a modern Python environment with Neovim
[AWS] Create a Python Lambda environment with CodeStar and do Hello World
Steps to create a Python virtual environment with VS Code on Windows
Create a Python3 environment with pyenv on Mac and display a NetworkX graph
Create a frame with transparent background with tkinter [Python]
Create a Vim + Python test environment in 1 minute
How to create a Python virtual environment (venv)
Create a LINE BOT with Minette for Python
Build a python environment with ansible on centos6
Building a Python environment with WLS2 + Anaconda + PyCharm
Create a page that loads infinitely with python
[Python] Build a Django development environment with Docker
[Note] Create a one-line timezone class with python
You can easily create a GUI with Python
When I tried to create a virtual environment with Python, it didn't work
Create a color bar with Python + Qt (PySide)
Create Nginx + uWSGI + Python (Django) environment with docker
A memo when creating a python environment with miniconda
Steps to create a Twitter bot with python
[Venv] Create a python virtual environment on Ubuntu
Commands for creating a python3 environment with virtualenv
Work in a virtual environment with Python virtualenv.
Create a decision tree from 0 with Python (1. Overview)
Create a new page in confluence with Python
Create a Photoshop format file (.psd) with python
Build a Python environment with OSX El capitan
Create a Python console application easily with Click
Create a Python execution environment on IBM i
[Docker] Create a jupyterLab (python) environment in 3 minutes!
Build a Python machine learning environment with a container