BWH-CCDS Data Science Pathway Resource Website

An entry-level resource for Data Science in Radiology


Project maintained by wfwiggins Hosted on GitHub Pages — Theme by mattgraham

Basic Setup Guide

This guide will step you through the process of setting up your development environment for using the command line to run programs in Python. The ideal OS to use is a Unix-based system such as MacOS or a Linux distribution (e.g. Ubuntu). For simplicity, I'll assume you're using MacOS, as Linux users probably won't need many of these tutorials.

For users on Windows 10, your best bet is to install the Windows Subsystem for Linux (WSL).

I recommend selecting the Ubuntu distribution directly from the Windows Store: WSL Ubuntu Installation Tutorial.

For users on Windows 7, your "best" bet is probably to install Cygwin, a terminal emulator for Windows that provides

a large collection of GNU and Open Source tools which provide functionality similar to a Linux distribution...

WSL and Cygwin should afford a similar experience to MacOS, though you may end up spending a little more time with Google and Stack Overflow to get certain elements of the your dev environment up and running.


Installing Developer Tools

Again, from here on out, we're assuming that you're using MacOS... I'll try to add support for WSL as this site evolves. However, I have little experience with Cygwin, so you're kind of on your own for now...sorry...

The first thing you should do is install the Xcode Command Line Tools via the linked guide. This will ensure that you have the full range of command line tools available to you - a necessary step before Advanced Setup.

Once you've done that, it's time to open up a terminal window. The easiest way to do this is to launch the Spotlight app via the keyboard shortcut {CMD-SPACE}, then type "terminal", followed by {ENTER}.

If you haven't already, this is the perfect time to head over to the Command Line page for an introduction to the CLI (or "shell").


Text Editors

Every programmer has his or her preferred text editor. I use Atom. I used to use Sublime Text. I dabble in vim for when I want to quickly edit a config file or a shell script without leaving my Terminal. I don't recommend vim to beginners. Sublime Text is sorta free and very configurable, but requires a little bit of work to get it setup initially. Atom is for-real-free works great out of the box, but is also configurable/extensible. I've heard VS Code is great (also free), but it doesn't play particularly nice with WSL, so I haven't really bothered to try it out. I'd recommend Atom to most beginners. But if you're unconvinced, you should do a little research and figure out which text editor might be best for you. Just pick a nice one with some simple features like syntax highlighting and it will make programming/coding a lot more fun...and efficient.


Installing Python with Anaconda

If you plan to do the Advanced Setup, now is the time to stop and head over there before continuing with these steps. If not, feel free to proceed.

Though Python comes preinstalled with recent versions of MacOS, I highly recommend using Anaconda (or Miniconda) for managing Python packages and virutal environments (more on these later). You could follow this link to download and install Anaconda with all of it's bells and whistles. However, since we're learning the command line, I recommend you go with Miniconda, a lighter-weight version without the Spyder IDE.

If you go with Miniconda, select the download for Python 3.7 64-bit bash installer for MacOSX. After the download is complete, enter the following command in your terminal: bash Miniconda3-latest-MacOSX-x86_64.sh. Follow any prompts that arise during the install process. Once this is complete, the next thing you'll want to do is test whether the install worked by entering a conda command (e.g. conda list). If this produces an error, then there are a couple of possibilities as to why this may not have worked, most of which should be fixed after the next step.

The next step is to check your shell config file, either ~/.bashrc or ~/.zshrc. Open this file in nano or your favorite graphical text editor. The Miniconda install process should have appended the following line to your "rc" file: export PATH="~/miniconda3/bin:$PATH". This command prepends the path to the Miniconda functions to your system path environment variable. If this is not the case, then you should add this line manually, save your changes and reload your shell (open a new terminal window or source your "rc" file).


Congrats!

You've completed Basic Setup. Time to move on to Advanced Setup or go straight to learning more about the command line, shell scripting, and Python!