Install Python3.7 with Numpy natively on M1 Mac

Viewed 2714

I need to Install Python3.7 to support Spark 2 on an M1 Mac.

I can get Python3.7 installed using pyenv, but when I try to install any of the data science libs, like numpy, I get failure: ModuleNotFoundError: No module named '_ctypes'

This seems to be related to libffi. Looking through the build logs for pyenv, I'm seeing this error:

.../Python-3.7.10/Modules/_ctypes/libffi_osx/include/fficonfig.h:51:2: error: "Unknown CPU type"
#error "Unknown CPU type"
 ^
1 error generated.

Python build finished successfully!
Failed to build these modules:
_ctypes               _decimal

Has anyone been able to successfully install 3.7 with numpy natively? I'm not looking for answers that involve Rosetta.

1 Answers

Use miniconda to install things: see this post.

Miniconda is an open source version of the conda package/environment manager, as an alternative to pyenv + brew.

It will install ARM native versions of python by default, as well as native versions of modules. This definitely include ARM native numpy.

I've quite sucessfully installed native python 3.7-3.10 and native numpy without any problems at all. (In fact ARM native versions of almost every package I use).

With conda you use conda to install packages, not pip.

So to install numpy you do conda install numpy in the environment you're in.

Related