You can now install python 3.9.1 through multiple pathways now but the most comprehensive build environment for the full data-science suite for python at the moment (Feb 2021) on M1 ARM architecture is via miniforge.
e.g.
brew install --cask miniforge
conda init zsh
conda activate
conda install numpy scipy scikit-learn
Answer from climatebrad on Stack OverflowYou can now install python 3.9.1 through multiple pathways now but the most comprehensive build environment for the full data-science suite for python at the moment (Feb 2021) on M1 ARM architecture is via miniforge.
e.g.
brew install --cask miniforge
conda init zsh
conda activate
conda install numpy scipy scikit-learn
You can now install Python 3.9.4 natively on Mac M1 (Apple Silicon). I'm using pyenv to install Python 3.7, 3.8 and 3.9 all native ARM. For example, to install 3.9.4:
$ pyenv install 3.9.4
python-build: use [email protected] from homebrew
python-build: use readline from homebrew
Downloading Python-3.9.4.tar.xz...
-> https://www.python.org/ftp/python/3.9.4/Python-3.9.4.tar.xz
Installing Python-3.9.4...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.9.4 to /Users/squademy/.pyenv/versions/3.9.4
For a complete guide on install pyenv and multiple Python version, you might read this article: https://squademy.medium.com/install-python-on-macos-11-m1-apple-silicon-using-pyenv-12e0729427a9.
Why Python native on M1 Max is gre… | Apple Developer Forums
Natively installing Python for machine learning on M1 | MacRumors Forums
macos - Install python@2 on Mac with M1 chip - Stack Overflow
Install python 3.6.* on Mac M1 - Stack Overflow
Videos
Hi. I just want to ask if there's something like a "safe" way to install Python 3 on Macbook Air m1. I'm learning Python right now, and MBA has Python 2.7 something version.
I could install 2.7.18 on M1.
brew install pyenv
pyenv install 2.7.18
Set the python version.
pyenv global 2.7.18
Export PATH if necessary.
export PATH="$(pyenv root)/shims:${PATH}"
Add if necessary.:
echo 'PATH=$(pyenv root)/shims:$PATH' >> ~/.zshrc
Sometimes you will get some errors like missing something if you are using rosetta then run:
arch -arm64 pyenv install 2.7.18
Copying from a GitHub issue.
I successfully installed Python 3.6 on an Apple M1 MacBook Pro running Monterey using the following setup. There is probably some things in here that can be removed/refined... but it worked for me!
#Install Rosetta
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
# Install x86_64 brew
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# Set up x86_64 homebrew and pyenv and temporarily set aliases
alias brew86="arch -x86_64 /usr/local/bin/brew"
alias pyenv86="arch -x86_64 pyenv"
# Install required packages and flags for building this particular python version through emulation
brew86 install pyenv gcc libffi gettext
export CPPFLAGS="-I$(brew86 --prefix libffi)/include -I$(brew86 --prefix openssl)/include -I$(brew86 --prefix readline)/lib"
export CFLAGS="-I$(brew86 --prefix openssl)/include -I$(brew86 --prefix bzip2)/include -I$(brew86 --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include -Wno-implicit-function-declaration"
export LDFLAGS="-L$(brew86 --prefix openssl)/lib -L$(brew86 --prefix readline)/lib -L$(brew86 --prefix zlib)/lib -L$(brew86 --prefix bzip2)/lib -L$(brew86 --prefix gettext)/lib -L$(brew86 --prefix libffi)/lib"
# Providing an incorrect openssl version forces a proper openssl version to be downloaded and linked during the build
export [email protected]
# Install Python 3.6
pyenv86 install --patch 3.6.15 <<(curl -sSL https://raw.githubusercontent.com/pyenv/pyenv/master/plugins/python-build/share/python-build/patches/3.6.15/Python-3.6.15/0008-bpo-45405-Prevent-internal-configure-error-when-runn.patch\?full_index\=1)
Note, the build succeeds but gives the following warning
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
running pyenv versions shows that 3.6.15 can be used normally by the system
After spending days following each and every tutorial on the Web without success, I found out thanks to a co-worker that a plain brew install pyenv followed by pyenv install 3.6 now works on M1.
$ sw_vers
ProductName: macOS
ProductVersion: 12.6.2
BuildVersion: 21G320
No rosetta, no x86 tricks, just plain ARM, maybe something has changed in the meantime?
Caveat: you could run into problems when using packages that do not yet run on ARM architecture natively, like PyTorch (experimental support only)
EDIT:
in the comments it's reported that pyenv install 3.6.15 works with
Mac mounting an M2 chipset with Ventura 13.4 OSX version, earlier Python versions couldn't be installed, though.