Skip to content Skip to sidebar Skip to footer

How Can I Run Python 3.9.1 Natively On M1 Mac?

Seems to be impossible currently with Anaconda as well as with Xcode 12. Via idle, it runs via Rosetta. There seems to be no discussion of this so either I'm quite naive or maybe t

Solution 1:

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

Solution 2:

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 openssl@1.1 from homebrew
python-build: usereadline 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: usereadline 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.

Solution 3:

I am using python3.9.4. I installed it using homebrew only.

I tried to install pandas by pip3 install pandas

It took a while but it got successfully installed in my M1 Macbook Pro.

Here's the log

❯ pip3 install pandas

Collecting pandas
  Downloading pandas-1.2.4.tar.gz (5.5 MB)
     |████████████████████████████████| 5.5 MB 855 kB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting numpy>=1.16.5
  Using cached numpy-1.20.2-cp39-cp39-macosx_11_0_arm64.whl
Collecting pytz>=2017.3
  Downloading pytz-2021.1-py2.py3-none-any.whl (510 kB)
     |████████████████████████████████| 510 kB 8.8 MB/s
Collecting python-dateutil>=2.7.3
  Downloading python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
     |████████████████████████████████| 227 kB 10.5 MB/s
Requirement already satisfied: six>=1.5 in /opt/homebrew/lib/python3.9/site-packages (from python-dateutil>=2.7.3->pandas) (1.15.0)
Building wheels for collected packages: pandas
  Building wheel for pandas (PEP 517) ... /

done
  Created wheel for pandas: filename=pandas-1.2.4-cp39-cp39-macosx_11_0_arm64.whl size=9354006 sha256=87fead2b2cacdfdc448c444899dfffca3b82275635ac8d51a39790ede623e342
  Stored in directory: /Users/pks/Library/Caches/pip/wheels/1c/18/1d/96f6fb133a77724bc42fce621a44162d840d037b9289c4a874
Successfully built pandas
Installing collected packages: pytz, python-dateutil, numpy, pandas
Successfully installed numpy-1.20.2 pandas-1.2.4 python-dateutil-2.8.1 pytz-2021.1

Solution 4:

I upgraded to 3.9.4

  1. Download the Python universal installer - https://www.python.org/downloads/mac-osx/

Note: I still could not get sudo pip install mysqlclient to install. I had add to

  1. update homebrew - See https://brew.sh
  2. Add /opt/homebrew/bin to PATH in .bash_profile (don't forget to source .bash_profile) or Add /opt/homebrew/bin to PATH in .zprofile (don't forget to source .zprofile) if using zsh

Post a Comment for "How Can I Run Python 3.9.1 Natively On M1 Mac?"