Getting python and your Github account up and running#

Introduction#

There are two key pieces of “tech” that we will use throughout this class:

  1. The python programming language

  2. The Github website for sharing computer code

Getting started with each of these requires a little initial setup. So, in this “assignment 0”, you will complete that setup. Then you’ll be ready for all of the computational work to come.

Python installations#

Python is the programming language we will use in this class.

On whatever computer you’re using, there is some version of python already installed and that you could use, if you really wanted to.

However, using the built-in installation of python on any computer creates all sorts of headaches. Later on we’ll go into more detail on why.

For now, it suffices to say that we’ll work with some other “installation” of python. In fact, we’ll use two:

  1. Google Colab

  2. Anaconda

Google Colab#

Google Colab runs your python code in the cloud. It is free; all you need is to login to Google Apps (which you have access to via your CUNY account) and then go to the URL linked above.

What does “in the cloud” mean?

Whenever you execute a python command, it runs on some computer. In the case of python installed on your computer, naturally it runs on your computer.

But in the case of Colab, it’s not using the python on your compute. Instead, it is using python installed on one of Google’s servers somewhere in the world that is connected to the internet.

So, via their web interface, you input the code you want to run, then Google sends it to that server, which runs the code, and then sends back to you the output. (FYI, oversimplifying a bit, but this is basically how everything works that’s called “in the cloud.”)

Anaconda#

These days, Google Colab is the single easiest and fastest way to get started working with and actually running python code.

However, any Earth data scientist worth their salt eventually needs to be able to run python on their own computer. (And, eventually, on a remote high-performance cluster, or HPC, not just their local laptop/desktop.)

As noted above, the builtin python won’t cut it for this. Instead, we use what’s called the Anaconda distribution of python.

Specific tasks for the python installations#

Get Google Colab running successfully#

This should be straightforward:

  1. Go to the Google Colab page linked above (dealing with the Google account login as needed)

  2. A button or link should pop up somewhere on that page that says something like “New notebook”. Click that.

  3. This will take you to a blank Colab document. At the top, below the navigation bars, should be an empty box with a little “play” symbol to its left. That is called a cell. Click inside that cell.

  4. Type in anything you want, and then click that “play” symbol. Doing so triggers Colab to try to execute or run the code that you’ve pasted in that cell. If what you entered is valid python code, the output of that code will show up immediately below. For example, if you copy-paste in print("hello world"), it will print the text hello world.

  5. If what you gave it is not valid python code—meaning it violates python’s syntax rules or has some other logic error, which are things we’ll explain later—then instead you’ll get an error message. For example, try instead pasting in print("hello world). (Do you notice the subtle difference from the first case?) That should result in a SyntaxError message.

  6. Keep playing around until you’ve gotten both a cell to run without error and a cell to result in an error message.

That’s it! You don’t actually need to turn anything in to prove you’ve done this. But if you get stuck on any step and just can’t figure it out, don’t be shy to ask the prof for help.

Get Anaconda or miniconda installed on your computer.#

If you are new to Python and especially if you’re on windows, use the full Anaconda distribution. Anaconda installs python, lots 3rd-party packages you’ll use, and other tools like a Graphical User Interface (GUI)-based app with lots of helpful tools for data science.

Anaconda vs. miniconda

If you already know what you’re doing decently enough and are comfortable working from the command line rather than a GUI app, you’re free to use miniconda instead. In that case, we’ll assume you don’t need much additional instructions, and so all of the instructions below are for the Anaconda version.

Anaconda can be downloaded from the Anaconda downloads page.

Your specific instructions are:

  1. Follow the anaconda download and installation instructions. Make sure the version you download is the right one for your operating system: Windows, Mac, or Linux.

  2. Open the Anaconda Navigator application that has been installed.

  3. Find the button, tab, etc. to open a new “Jupyter Notebook.” Click it.

  4. A screen should pop up that looks a lot like the Google Colab we opened earlier. (In fact, under the hood Google Colab is simply a web-hosted Jupyter notebook).

  5. Do the same steps as above for Colab: play around and get a cell to run successfully at least once and to give an error message at least once.

Github#

Basically, Github is a website where you can share computer code with other people. In addition to just hosting code that you upload to it, Github also provides lots of tools for collaborating with other people on some shared code.

(Other, similar online repositories exist such as gitlab and bitbucket, but we won’t use these. Github is by far the most popular and thus the one that’s most valuable for you to learn.)

The first step in using Github is creating an account. This is 100% free. Github offers premium features that you can pay for, but we will not be using those. (Your prof’s account is the free version, in case that helps.)

If you don’t have a Github account: sign up for one using your CCNY/CUNY email#

Go to this link, fill in whatever they need from you, and click OK.

Fill out this Google form, in which you’ll provide your Github account handle.#

I’ll use this to grant you permission to write to the class Github repo, which you’ll need for the next step.

Go to this Issue on the class Github repo, and reply in the thread following the instructions there.#

Congratulations! You’ve contributed to an Issue on Github, perhaps for the first time!

Extra credit (none this assignment)#

Most assignments will provide one or more ways of earning extra credit, up to 5, 10, or 15% of the total assignment grade. Look for this in future assignments.