{ "cells": [ { "cell_type": "markdown", "id": "87ae35d4", "metadata": {}, "source": [ ":::{include} ../../../textbook-header.md\n", ":::\n", "\n", "\n", "## Launch Jupyter Notebook From the Terminal\n", "\n", "Throughout this chapter, you will learn how to use `Jupyter Notebook` to write and document your `Python` code. First, you need to know how to open `Jupyter Notebook`, which is done in the `Terminal`.\n", "\n", "It is ideal (but not required) to launch `Jupyter Notebook` from the working directory where all of the notebook files that you wish to use live, so you can easily access the files you need.\n", "\n", " **IMPORTANT:** the `jupyter notebook` command requires that you have `Jupyter Notebook` installed on your computer! `Jupyter Notebook` was installed when you created the `earth-analytics-python` environment as a part of the setup for this textbook. Be sure to activate the environment in the terminal using the command `conda activate earth-analytics-python` before launching `Jupyter Notebook`.\n", "{: .notice--success}\n", "\n", "\n", "### Use Bash to Change to Your Working Directory\n", "\n", "Begin by opening your terminal (i.e. `Git Bash` for Windows or the `terminal` on Mac or Linux). \n", "\n", "Change the current working directory to your desired directory (e.g. `earth-analytics` under your home directory) using `cd directory-name`.You can then check that the current working directory has been updated (`pwd`).\n", "\n", "```bash\n", "$ cd ~/earth-analytics\n", "$ pwd\n", " /users/jpalomino/earth-analytics\n", "```\n", "\n", "### Begin a Jupyter Notebook Session From the Terminal\n", "\n", "Now you can start a new `Jupyter Notebook` session by typing the command `jupyter notebook` in the `Terminal`.\n", "\n", "```bash\n", "$ jupyter notebook\n", "```\n", "\n", "
\n", " \n", " \"You\n", "
You can use Shell (Terminal) to open Jupyter Notebook with the command, Jupyter Notebook.\n", "
\n", "
\n", "\n", " **NOTE:** If you get an error `jupyter: command not found`, this means that you have not activated the conda environment that you installed for this textbook. Be sure to activate the environment in the terminal using the command `conda activate earth-analytics-python` before running the `jupyter notebook` command.\n", "{: .notice--success}\n", "\n", "When you type this command into the terminal, it will launch a local web server on your computer. This server runs the `Jupyter Notebook` interface. \n", "\n", "You will notice that the `Terminal` is running commands to start your `Jupyter Notebook` session. Be sure to leave the `Terminal` open while you use `Jupyter Notebook`. It is running a local server for `Jupyter Notebook` so that you can interact with it in your web browser. \n", "\n", "
\n", " \n", " \"This\n", "
This is what the Terminal looks like with a Jupyter Notebook session running.\n", "
\n", "
\n", "\n", "If your commands were successful, your default web browser will open with a new tab that displays your `Jupyter Notebook` dashboard.\n", "\n", "The dashboard serves as a homepage for `Jupyter Notebook`. Its main purpose is to display the notebooks and files in the current directory. \n", "\n", "
\n", " \n", " \"This\n", "
This is what Jupyter Notebook dashboard will look like when you launch it. If there are any directories and files, you will see them listed in the dashboard, just like the data directory and notebook called week1.ipynb are listed in this image.\n", "
\n", "
\n", "\n", " **Data Tip:** While `Jupyter Notebook` looks like an online interface, when you launch it from the terminal, like you did in this lesson, it is actually running locally on our computer. You do not need an internet connection to run `Jupyter Notebook` locally.\n", "{: .notice--success}\n", "\n", "## Navigate Files Using the Jupyter Notebook Dashboard\n", "\n", "To find files in the Jupyter Notebook dashboard, you can click on the name of a directory (e.g. `ea-bootcamp-day-1`), and the dashboard will update to show you the contents of the directory. \n", "\n", "
\n", " \n", " \"You\n", "
You can click on the name of directory in the Jupyter Notebook Dashboard to navigate into that directory and see the contents.\n", "
\n", "
\n", "\n", "You can return to the parent directory of your current directory in the `Jupyter Notebook` session by clicking on the folder icon on the top menu bar. \n", "\n", "
\n", " \n", " \"You\n", "
You can use the Jupyter Notebook dashboard to return to the parent directory of any subdirectory.\n", "
\n", "
\n", "\n", "\n", "## Create New Jupyter Notebook Files\n", "\n", "You can create new `Jupyter Notebook` files (.ipynb) from the dashboard.\n", "\n", "On the top right of the dashboard, there are two buttons for `Upload` and `New`. `Upload` allows you to import an existing `Jupyter Notebook` file (.ipynb) that is not already in that directory.\n", "\n", "You can create a new `Python 3` `Jupyter Notebook` file (.ipynb) by clicking on `New` and selecting `Python 3`. A new notebook will open a new tab in your web browser. \n", "\n", "
\n", " \n", " \"When\n", "
You can use the Jupyter Notebook dashboard menu to create new Jupyter Notebook files (.ipynb) by clicking on the New button and selecting Python 3. \n", "
\n", "
\n", "\n", "## Open Jupyter Notebook Files\n", "\n", "You can open existing `Jupyter Notebook` files (.ipynb) in the `Jupyter Notebook` dashboard by clicking on the name of the file in the dashboard (e.g. `filename.ipynb`). \n", "\n", "Note: if you don't see the `Jupyter Notebook` file (.ipynb) or directory that you are looking for, you may need to navigate to another directory in the dashboard (see above). You may also need to launch the `Jupyter Notebook` from a different directory. \n", "\n", "## Close Your Jupyter Notebook Session\n", "\n", "### Close and Shutdown Jupyter Notebook Files\n", "\n", "To close your `Jupyter Notebook` files (.ipynb), you can close the browser tab displaying the notebook, but you still need `Shutdown` the notebook from the dashboard. \n", "\n", "To `Shutdown` a Jupyter Notebook file (.ipynb), click in the checkbox to left of the filename. You will see an orange button named `Shutdown` appear in the top left of the dashboard menu; click on it to `Shutdown` any file that is checked in the list.\n", "\n", "
\n", " \n", " \"You\n", "
You can shutdown Jupyter Notebook files using the Shutdown button on the Jupyter Notebook Dashboard.\n", "
\n", "
\n", "\n", "### Shutdown the Jupyter Notebook Local Server\n", "\n", "After all of your notebooks are closed and shut down, you can end your `Jupyter Notebook` session by clicking on the QUIT button at the top right of the dashboard. You can now close the browser tab for `Jupyter Notebook`.\n", "\n", "If desired, you can also close your terminal by typing the command `exit` and hitting Enter.\n", "\n", ":::{note}\n", "\n", "You can also shutdown a `Jupyter Notebook` session by clicking in the `Terminal` window and clicking Ctrl+c. You will be asked to confirm that you want to `Shutdown this notebook server (y/[n])?`. Type `y` and hit `Enter` to confirm. Then, you can close the `Terminal` by typing the command `exit` and hitting Enter.\n", "\n", ":::" ] } ], "metadata": { "file_format": "mystnb", "jupytext": { "text_representation": { "extension": ".md", "format_name": "mystnb", "format_version": 0.13, "jupytext_version": "1.14.7" } }, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "myst": { "substitutions": { "authors": "Jenny Palomino, Leah Wasser", "excerpt": "The Jupyter ecosystem contains many useful tools for working with Python including Jupyter Notebook, an interactive coding environment. Learn how to launch and close Jupyter Notebook sessions and how to navigate the Jupyter Dashboard to create and open Jupyter Notebook files (.ipynb).\n", "objective": "* Launch and close a `Jupyter Notebook` session.\n* Navigate the `Jupyter` dashboard.\n* Create and open `Jupyter Notebook` files (`.ipynb`).", "title": "Get Started With Jupyter Notebook For Python" } }, "source_map": [ 23 ] }, "nbformat": 4, "nbformat_minor": 5 }