3

I have an M1 processor from Apple, which is a new ARM64 architecture, and the binaries provided for many data science Python packages will not run on it, and compiling them fails in most cases.

Questions such as How to install SciPy on Apple Silicon (ARM / M1) or numpy build fail in M1 Big sur 11.1 offer many different answers, some of which work and most don't. However, even for those that manage to make the modules compile, I don't understand how I can make pip install my locally compiled packages instead of fetching them (and failing) from pypy.

How can I install numpy, scipy, numexpr and others as a dependency on a computer with an M1 processor?

MattiSG
  • 3,796
  • 1
  • 21
  • 32

1 Answers1

3
  1. Install Miniforge with Homebrew to compile these modules locally: brew install miniforge.
  2. Install the modules you need with conda instead of pip: conda install numpy (and scipy, numexpr…).
  3. In the environment in which you install your dependencies (global, user or virtual environment with venv, pew or similar), install as you would usually, but let your package manager know to load these native modules you installed earlier by defining PYTHONPATH: prefix the install command with PYTHONPATH=/opt/homebrew/Caskroom/miniforge/base/pkgs/:$PYTHONPATH. For example: PYTHONPATH=/opt/homebrew/Caskroom/miniforge/base/pkgs/:$PYTHONPATH pip3 install.
MattiSG
  • 3,796
  • 1
  • 21
  • 32