Easily install Python using Pyenv on your M1 Mac(Apple Silicon)

We all love the speed and snappiness of M1, and Python of course needs no introduction. However, by default, the python version it ships with is python2.

Here’s how to check the same :

Now, Let’s install pyenv to manage multiple versions of Python. Just like any other thing in life, there are multiple ways to install pyenv on your mac.

Today we shall be taking a look at the simple method using git, all in 8 simple steps. So without further ado, let’s get started.

Git Method

Step 1: Clone the pyenv folder to your local home

$ git clone https://github.com/pyenv/pyenv.git ~/.pyenv
$ cd ~/.pyenv && src/configure && make -C src

Step 2: Edit your zhrc file and add the following

$ vi ~/.zshrcexport PYENV_ROOT="$HOME/.pyenv" 
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"

Step 3: Restart your terminal. Now pyenv should be activated and you can start to install some Python.

Step 4: Here’s how your system should look right about now

Step 5: Now, as per the recommendations given by pyenv suggests that before installing any version of Python, we need a Python build environment for Mac, so we first install Xcode Command Line Tools

$ xcode-select --install

Step 6: Now, now we install brew dependencies which are required. Note : This might take a while.

$ brew install openssl readline sqlite3 xz zlib

Step 7: Finally we install python 3.7 on our Macos using the following command

$ pyenv install 3.7.10

Step 8: Verfication Time !!

List all Python versions managed by pyenv:$ pyenv versions
* system (set by /Users/squademy/.pyenv/version)
3.7.10

Set the default python to 3.7.10, cause that's what I want when typing python on the terminal

$ pyenv global 3.7.10 $ python --version 
Python 3.7.10

Verify pyenv shims is activated on the PATH:

$ type -a python
python is /Users/squademy/.pyenv/shims/python
python is /usr/bin/python

$ which python
/Users/squademy/.pyenv/shims/python

--

--

--

I'm just another Python Lover, Machine Learning tinkerer and Explainable Ai Enthusiast.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

“I Don’t Trust Anything That We Didn’t Build”

Configuring AWS ASG and testing the policy

Widgets 14 | PopupMenuButton

Daily links of Fernand0 — Enlaces diarios de Fernand0 — Issue #268

Usage of radio vs checkbox button elements in HTML

How to decrease your Gradle build time by 65%?

Working with Node Selector & Node Affinity In Kubernetes

CS373 Spring 2022: Martin Nguyen

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Devesh Surve

Devesh Surve

I'm just another Python Lover, Machine Learning tinkerer and Explainable Ai Enthusiast.

More from Medium

How to Quickly Anonymize Personal Names in Python

A Tensorflow Solution For Mac M1 That Really Works.

Bioinformatics for data scientists-Find the topmost frequent k-mers in a genomic segment

Intro to Python ast Module