This document describes how to use Penn State’s Jupyter notebook server system.
psu wifi on campusYou should see the following login screen:
knitr::include_graphics("../img/jupyter-psu-pre-login.jpg")
Jupyter notebook server login screen
You should then see the following screen:
knitr::include_graphics("../img/jupyter-psu-post-login.jpg")
Jupyter notebook post-login
More than once I have failed to connect to the server. Why? Because my laptop likes to jump on the eduroam network sometimes. This is great when I’m traveling, but not when I need access to Penn State services.
To create your first notebook, click on the New drop down menu in the upper right corner. Select Python 3. Why not Python 2? It’s a long story, but Python 2 has been deprecated for some time. That means it’s nearing the end of the time when it will be actively supported and maintained.
Creating a new Python 3 Jupyter notebook will look like this.
knitr::include_graphics("../img/new-jupyter-nb.jpg")
New Jupyter notebook
I like to name my notebooks right away. Notice the Untitled label on the upper left of the window. Click on Untitled to open a new window where you can rename your notebook.
knitr::include_graphics("../img/jupyter-rename-notebook.jpg")
Renaming a notebook
In general, I try to name files with dashes rather than spaces, for example, ricks-jupyter-notebook. The reason is that names without spaces work better with Linux-style file systems–not always, but more often. When you have named your notebook, hit the Rename button to close the Rename Notebook window and return to the Jupyter notebook.
There are several ways of opening old notebooks. I suggest clicking on the Jupyter icon in the upper left to bring up the notebook you saw when you logged in. This should show you a list of files in your PASS space directory, but as of 2020-01-08 there is a bug. Instead, click on the Running tab. This will show you a list of Terminals and Notebooks. Click on one of your old notebooks, and it will launch.
The base configuration of Python 3 comes with many useful packages, but you may want to install others for your notebooks.
For example, to install the censusdata package, issue the following command within a Python notebook cell:
!pip install --user censusdata
The exclamation point ! tells the notebook to access the system shell. pip is a package installer for Python. The --user flag tells the system to install the package for the use of you, the user, alone. And, censusdata is the package. Execute the cell with command+enter, and the package will install.
I recommend a few basic packages to install right away.
!pip install --user pandas # for data science
!pip install --user numpy # for numerically intensive computing
!pip install --user matplotlib # for plotting
You should only need to do this one time. The changes should propagate across other notebooks you create.
You may also choose to install packages using a terminal application that the Jupyter notebook environment makes available.
From the main Jupyter page, click on the “Running” tab to see whether there are any active terminals.
knitr::include_graphics("img/jupyter-terminal.png")
If there are, you may click one one of them to activate it. In this case, there are not, so we go to the “Files” tab, and select the “New” drop down menu from the far right side, and then select the “Terminal” command.
knitr::include_graphics("img/new-jupyter-terminal.png")
A new Linux terminal opens in a new window.
knitr::include_graphics("img/jupyter-terminal-window.png")
You can now enter your installation commands here. Note:We don’t need the ! because we are not issuing this commands in the Jupyter notebook.
pip install --user pandas # for data science
pip install --user numpy # for numerically intensive computing
pip install --user matplotlib # for plotting
While you’re here, you might as well look around. Try listing the directory’s contents.
ls
If you find a pass-dir using the terminal commands above, you can navigate to it using the cd or change directory command. If you don’t want to navigate to it, you can list the contents using ls.
Note:If you can’t ls the directory, then you will have to do a few extra steps (HT to Matt Hansen at TLT for helping me sort this out.)
klist command. If youkinit at the terminal and enter your password when you see the …@dce.psu.edu prompt.klist again to verify that you have an active Kerberos ticket.ls pass-dir.You may want to browse to pass-dir in the Jupyter interface prior to within the notebook because PASS has many nodes and they are accessed “on demand” and access might timeout within the notebook the first time.
You can use the WebFiles application to upload files to your PASS space.
It’s not required, but it’s certainly good (computer) manners to log out. Press the Logout button in the upper right hand corner to do so. That will bring you back to the login screen.