General Setup for Data Science Projects in Python

Before you begin your first data science project using Python, it’s helpful to make sure that your computer is properly set up for the task. I broke this process down into manageable steps to help you get get started.

Christine Egan
4 min readApr 4, 2021
Image by Renate Becker from Pixabay

Note to readers: Since the internet is full of outdated advice, it’s wise to check when directions or solutions have been written. It’s also helpful to know what system and specifications the author was working on. I’m using an Apple MacBook Air, Early 2015 that is running macOS Catalina Version 10.15.7. So these instructions will apply to users with the same or fairly similar setup. If you’re using an older operating system these steps should still work, but there may be areas where adjustments are needed, which I will try to note.

I. Hello Python
Python will already be installed on your computer, but it’s fairly certain that it is outdated. If your Mac is from 2015 like mine is, it will likely come with Python 2.7.7 out of the box. To get started, you will need the newest version of Python installed on your system.

Navigate to python.org > Downloads > Mac OS X and download the current version (as of December 2020, 3.9.0). You can just use the graphical installer if you wish. The installer should launch as soon as package downloads, and once you’re through all of the red tape, you’ll have a new version of Python available for use.

screen shot of python.org
python.org

II. Meet the Terminal
Go to your launchpad and select Other. There, you will find an app called Terminal. Open it up, and when it shows up in your dock, right click to keep it in the doc. You’re going to need it.

screen shot of the “other” folder on Mac OS X launch pad

III. Using Bash in Terminal Install Homebrew, CLT and Xcode
You may already have Homebrew on your Mac, but if you do not open your web browser and head over to Homebrew.

Bash and Zsh
If you are using Mac OS Catalina or newer, you will need to switch the mini language in your terminal from Zsh to Bash to follow these instructions. This is easy, so don’t panic.

To find out if you are using Zsh or Bash, simply look at the text on the left side of the terminal. If it looks similar to the line below, it’s Zsh:

my-computer%

If it looks like this, it’s Bash:

my-computer$

The difference is that Zsh will use % and Bash will use $.

To switch to Bash simply enter:

bash

The computer will return instructions to switch back to Zsh if you wish later on. From now on, when you see a code box with a $ before the command, you’ll know that the command is Bash.

Your screen should look something like this:

screen shot of a terminal switching from zsh to bash

Command Line Tools (CLT) for Xcode
Homebrew requires that this package be installed on your system in order to use Homebrew. We are going to do this, but first we have to set up the terminal just right.

To install Command Line Tools, enter:

$ xcode-select — install

It might take a little while for everything to download. Follow the instructions of any prompts if they happen to pop up along the way.

Homebrew
Now, you can move onto installing Homebrew by entering the following:

$ mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz — strip 1 -C homebrew

This will automatically install Homebrew inside your /usr/local directory.

IV. Using Homebrew to Install Python & Pip
Homebrew has been installed, and now it’s time to make sure that Homebrew has its very own Python. There are going to be a lot of different versions of Python on your computer. This step is making sure that your package manager is connected to its own version.

Python and Pip

To install the latest version of Python with Homebrew, enter the following:

brew install python 

Homebrew will install its own copy of the newest version of Python. Pip is a package manager included when you download Python. The reason why Homebrew and other programs, packages, and apps need their own version of Python is because the Python that is already on your Mac is there for a reason. Altering or removing it can really mess up your computer and make it unusable unless you do a hard reset.

V. What Did We Do?
1. Verified what machine and OS you are using.
2. Installed the newest version of Python to date.
3. Introduced ourselves to the terminal.
4. Learned how to switch from Zsh to Bash, and how to tell which one we are using.
5. Installed Xcode, and subsequently Command Line Tools.
6. Installed Homebrew
7. Installed a version of Python especially for Homebrew, using Homebrew.

Now you have your foundational package management set up that we will build upon to set up your data science environments. Next, you can follow this tutorial to create a virtual environment for your project.

--

--