31

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 this will be useful to others as well.

Python says: "As of 3.9.1, Python now fully supports building and running on macOS 11.0 (Big Sur) and on Apple Silicon Macs (based on the ARM64 architecture). A new universal build variant, universal2, is now available to natively support both ARM64 and Intel 64 in one set of executables" https://docs.python.org/3/whatsnew/3.9.html

Please help a newbie figure out how to take advantage of his recent impulse-buy.

hithisispeter
  • 359
  • 1
  • 3
  • 5

5 Answers5

26

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
climatebrad
  • 1,286
  • 8
  • 13
  • 3
    Thanks for your reply. The question is about running natively, not through Rosetta translation. Running python 3.9.1 on the ARM M1 chip, Python processes are labeled 'Intel Architecture' in Activity Monitor. This seems like a compiler problem. How do I compile to run natively on the ARM chip? This happens through Anaconda as well as Xcode 12. – hithisispeter Feb 10 '21 at 19:22
  • 2
    I'm not sure how you set it up. The [homebrew installer](https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/miniforge.rb) does correctly install the ARM version of miniforge on M1 chips. – climatebrad Feb 12 '21 at 18:42
  • 1
    Well it works. But the problem is that you are not allowed to use Anaconda in a commercial context. :( I hope it will become possible with a regular Python installation soon, so I can use my Mac Pro at my company. – ali Mar 03 '21 at 10:56
  • 2
    What does “not allowed to use anaconda in a commercial context” mea? – yts61 Apr 15 '21 at 23:23
  • I refuse to use conda – Connor Jul 16 '22 at 21:02
  • The conda-forge offshoot from conda provides native ARM MacOS versions of miniforge and mambaforge (https://github.com/conda-forge/miniforge) along with a fair assortment of packages. – bht Jan 13 '23 at 04:02
16

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: 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.

Eugene
  • 607
  • 3
  • 8
  • 12
14

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

brew install python@3.9

Also you may want to do the following to unlink and check the version number

brew unlink python3
brew link python3.9
python3 --version
Yada
  • 30,349
  • 24
  • 103
  • 144
3

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
C Wilke
  • 31
  • 5
  • 3
    does this assume your shell is bash and not zsh? with macos's change to zsh i thought we have to update `.zprofile`, not `.bash_profile`, now. – william_grisaitis May 19 '21 at 19:04
  • 2
    You are correct! I was using old scripts on bash so had to update bash_profile. I updated the answer to include .zprofile. – C Wilke Jul 11 '21 at 03:08
1

No brew required (except drinking the joyful one at the end of the day) -

Simply download the desired universal2 version from Python Releases for macOS.
(These versions will work for both Intel and Mn (eg M1, M2) Macs.)

The downloaded file is a .pkg file, which, as expected, you double-click to install.

The process will place some informational files and version-specific IDLE and Python Launcher apps under a version-specific folder in Applications. It will also install the appropriate python executable in the system frameworks folder, eg /Library/Frameworks/Python.framework/Versions/3.10/Python

Now,

  • You can use a virtual environment, such as the one included in PyCharm or explained in python.org's tutorial for Virtual Environments and Packages, by using the appropriate framework version.

  • You can use the version-specific IDLE app from within the Applications folder.

  • You can run scripts, without being in Terminal, by either dragging/dropping them onto the Python Launcher app's dock icon OR associating the .py extension with the launcher app (which will allow you to simply double-click a script in Finder to run it with the launcher app).

Note that if you associate the Launcher app with files, and you have multiple python versions installed on your Mac, you might want to customize the extension for the python version you're using (eg, .py3.10 instead of just .py). That way you can associate a specific version of the Launcher app with the specific version of python you need for the script.

leanne
  • 7,940
  • 48
  • 77