Setting up Python for Machine Learning course work

Simple, short guide to setup Python and some Machine Learning libraries in a macOS computer.

Pyenv

First make sure that you have homebrew installed:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" 

Install pyenv using homebrew:

brew update && brew install pyenv

Then update your .bashrc or .zshrc file to include the path of pyenv, run the following in a terminal:

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"'

Then restart your shell by running the following:

exec "$SHELL"

Installing a specific python version

pyenv install 3.8.5

Installing common ML libraries

python --version
# Python 3.8.5

And also make sure that pip (the python package manager) points to the location of the same version:

pip --version
# pip 20.1.1 from /Users/tristian/.pyenv/versions/3.8.5/lib/python3.8/site-packages/pip (python 3.8)

Finally upgrade pip to the latest version:

pip install --upgrade pip

Install the libraries

We will be installing the following libraries:

  • Scikit-Learn
  • Pandas
  • Numpy
  • Matplotlib
  • Seaborn
  • Jupyter

They can all be installed with the single following command in a terminal:

pip install -U scikit-learn pandas numpy matplotlib seaborn jupyter

The command might take a bit but after it finishes you should be ready to start ML’ing away!

--

--

iOS Engineer with a love for automation and internal tooling. Gopher, Pythonista and Haskeller by night. https://www.linkedin.com/in/aztristian/

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
Tristian Azuara

iOS Engineer with a love for automation and internal tooling. Gopher, Pythonista and Haskeller by night. https://www.linkedin.com/in/aztristian/