Python setup on macOS with emacs #

Focus on M1 tips.

pyenv #

pip #

numpy and matplotlib on M1 #

It’s not super easy to install matplotlib on the new M1 Macs and you may be greeted with an error like

ImportError: dlopen(/opt/homebrew/lib/python3.9/site-packages/, 2): no suitable image found.  Did find:
	/opt/homebrew/lib/python3.9/site-packages/ mach-o, but wrong architecture
	/opt/homebrew/lib/python3.9/site-packages/ mach-o, but wrong architecture

I found this guide on StackOverflow that seemed to describe my exact issue. I followed the commands there but couldn’t get it to work.

And then I tried Miniforge, specifically the version designed for Apple Silicon, which installed a Python environment using conda that worked immediately, just as suggested in this thread. I still don’t quite understand why.

  • A great post by Samuel Colvin, the author of type-hint package pydantic, about his plans for v2.