Jupyter Notebook Installation Guide (Mac)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

Jupyter Notebook Installation Guide for OS X

Physics 104/6
Queen’s University

For the rest of our PTLs this year, we will be using a software package
called Jupyter Notebook. As we begin to learn together how to use Jupy-
ter Notebook, you’ll get to see how it’ll help you organize your work as
well as take care of a lot of the grunt work done in data analysis.
You may find the learning curve steep as you learn how to use Jupyter
Notebook, but the more you use it, the easier it’ll become. And take
heart that you’re using the software that thousands of research physi-
cists around the world are using everyday to do real science!
Let’s get started!
1. Download Anaconda



 Go to: https://www.continuum.io/downloads#osx
 Click on “GRAPHICAL INSTALLER” under the Python 3.5 version. IT IS VERY IMPORTANT TO USE THE 3.5 VER-
SION!
2. Save Anaconda Installer and Open

 Anaconda will start download (it may take a minute or two)


 Once complete, you can double-click on it in your “Downloads” dropdown in Safari
3. Install Anaconda

 As Anaconda installs, you’ll be asked a series of questions. Answer “Continue”, “Continue”, “Continue”,
“Continue”, “Agree”, “Install for me only” then “Continue”, “Install”, “Close”
 You’re done once you click “Close”. You just installed Anaconda. No big deal.
4. Open Terminal

 We now need to start up an app called “Terminal”


 To start it go into “Finder”, and then under “Applications”, click on the “Utilities” folder and then select
“Terminal”
 A new window should now open
5. Install QExPy

 To install QExPy (the software from Queen’s we’ll be using), we’ll use Terminal. In Terminal, we are given a
place where we can type commands for the computer to follow
 In our case, we’ll type “pip install qexpy”. CHECK YOUR SPELLING!
 Then to have the computer do this, we press the Enter key
6. Make Sure QExPy Installed Correctly

 Once you pressed Enter in the previous step, you may have noticed a bunch of “computer code” flashed by.
This is just your computer letting you know what it’s doing
 At the end of the day, just make sure that the last few lines say something along the lines of “Successfully
installed qexpy-0.3.5”. The last digits in this might be different, but don’t worry about that! If its not success-
ful, make sure you followed the previous steps carefully, and let your LF know in your PTL
 Feel free to close Terminal once this is complete
 Sometimes you may need to update QExPy, so in that case please refer to the “Guide to Updating QExPy” at
the end of this package
7. Make a Folder for your Jupyter Notebooks

 As we move through the journey known as Physics 104/106 together, it’ll be useful to have a folder where
you can save all your Jupyter Notebooks
 We’re actually quite constrained as where we can make this folder, so open “Finder”, and then click on
“Documents”. MAKING THE FOLDER HERE IS CRITICAL!
 Then create a new folder. Call it “Jupyter Notebooks”
8. Start-up Anaconda Navigator

 Next we need to start-up an app called “Anaconda Navigator”. From this app, we’ll launch Jupyter Notebook
 To find Anaconda Navigator, open Finder and go to Applications
 Then open the “anaconda” folder and then click on “Navigator”
9. Start-up Jupyter Notebook

 Once Navigator opens, you’ll see a variety of Anaconda apps that you can use
 For our purposes, we’ll launch Jupyter Notebook by clicking the “Launch” button (NOTE: you may or may
not have all the apps shown in the image above)
10. Jupyter Notebook Starts-up

 As Juypter Notebook starts-up, this windows (or terminal) will appear


 DO NOT CLOSE THIS UNTIL YOU’RE DONE WITH JUPYTER NOTEBOOKS
 For those of you who are curious, this is a local server on which Jupyter Notebooks will be running and
you will connect to via your web browser. Pretty dope, right?
11. The Jupyter Notebook Window

 Along with the previous terminal, a web browser window will open with the address “localhost:8888/
tree” (aka a browser window connected to Jupyter Notebook)
 You’ll see the folders and files from your computer in this window. We want to find the “Jupyter Notebooks”
folder we created back in Step 7, so we’ll click on the “Documents” folder
12. Opening the Jupyter Notebook Folder

 Once inside of the Documents folder, we can know see all our documents, along with the “Jupyter Note-
books” folder we made earlier
 Click on this folder to go into it
 Every time you use Jupyter Notebook, make sure you go to this folder once you start it up
13. Make a New Folder

 We’ll want to keep all our notebooks and files organized, so let’s create a new folder
 On the top right, click “New” and then select “Folder”
 You’ll notice a new folder called “Untitled Folder” will appear
14. Rename Your Folder

 To rename this folder, check off the box beside “Untitled Folder”
 A “Rename” button will appear at the top left. Click this, enter the name “My First Notebook”, and then
press Enter
 Then click on “My First Notebook” to enter your new folder
15. Create a New Notebook

 Now that we’re in our new folder, let’s make a our first Jupyter Notebook
 Click on “New” again in the top right, and now under “Notebooks”, select “Python [Root]” (or “Python3” or
“Python [conda root]” on some computers)
 And BAM!, a new browser tab will open, and there you have it, your first Notebook (audience applauses
whole-heartedly)
 You can also go back to main notebook tab (the first one that opened) if you want to open more Notebooks
16. Name and Save Your Notebook

 To name our snazzy new Notebook, we can click on “Untitled” at the top of the notebook, enter the name
of your notebook (Ex. Dave’s Super Snazzy Notebook), and press “OK”
 To save it, press the “Save” button on the top left
17. Getting Ready to Write

 Jupyter Notebooks are made up of cells, and for each cell, we can set whether that cell will be for explaining
something (called “Markdown” cells) or for running some code (called “Code” cells)
 By default, our notebook has one Code cell (where the red arrow is pointing), but we can change it to a
Markdown cell by clicking on the “Code” dropdown menu, and selecting “Markdown”. You’ll notice that the
“In []:” disappears from the cell
18. Writing in a Notebook

 To write in your Notebook, simply click on the cell, and type away. You can use the above example if you
want to see what the hash symbol does
 Once you’re done type, press “Shift” and “Enter” at the same time. Voila! Words!
19. Editing Text

 To edit what you just wrote, simply double-click on the cell you want to edit, and it’ll pop back into edit
mode
 Press “Shift” and “Enter” once you’re done
 And don’t forget to save often so you don’t lose any work!
20. Saving a PTL Jupyter Notebook

 On the On Q course page, you can download an example PTL Notebook titled “My First PTL Notebook.zip”
 Download this zip file and save it in your “Jupyter Notebooks” folder you made in Step 7
 Then find this file in “Finder”, right-click on it, select “Open With”, and choose “Archive Utility”
 Once done, you can delete the downloaded zip file, leaving the new folder for you to use
21. Opening a PTL Jupyter Notebook

 Then back in the web browser tab that has your “Jupyter Notebooks” folder open, you should now see a
“My First PTL Report Notebook” folder
 If not, refresh the web page
 Click on this folder to go into the folder
22. Opening a PTL Jupyter Notebook

 Once in the “My First PTL Report Notebook” folder you should see a file called “My First PTL Report Note-
book.ipynb”, with a little notebook symbol beside it
 Click on this file, and a new browser tab will open with this notebook
 Take a look at it to get a small sneak peak for what your PTL will look like for next week
23. Closing a Notebook and Juypter Notebook

 Once you’ve saved your work, you can close a notebook by simply clicking the “x” on the web browser tab
with it open
 If you’re done with Jupyter Notebook all together, you can close the web browser tab showing your folders,
and then close the terminal that is running by clicking the “x”
 That’s all there is to it! Great job!
Guide to Updating QExPy
Updating QExPy (1/2)

 Open up “Terminal”, just as in Step 4


 First type “conda update --all -y” CHECK YOUR SPELLING!
 Then press Enter to have the computer run this. Then just as when you installed QExPy, a much of text will
be displayed, showing what your computer is doing (this may take a while!)
Updating QExPy (2/2)

 Once the terminal stops displaying new text and you can type again, type in “pip install --upgrade qexpy”
 Press Enter to have the computer run this, and again some text should be displayed to show the progress
 Once this finishes and no more new text is being displayed, you’re done! You can close Terminal now

You might also like