This guide describes the best practice for using Jupyter Notebooks (or Jupyter Lab) on your SAIL Desktop. These are different from JupyterHub (for that guide, please see JupyterHub Guide). Still, unless your project is paying for JupyterHub access, you will want to follow the guide on this page.
The page is split into two sections - the first is a basic set of instructions for setting up and using Jupyter Notebooks (referred to here as 'JNBs'). The second is the same instructions explaining the reasoning behind each step.
Basic Instructions
Initial setup
This is for people who have not previously configured Anaconda or Jupyter on their desktops.
- Log on to your SAIL desktop.
- Click on the Start menu (the little Windows icon on the bottom left) → Anaconda3 (64-bit) → Anaconda Prompt (Anaconda3). This will open a command line window with a line of text like:
- (base) C:\Users\<your username will be here>
- Now we need to make an environment to use. In this command line window, type the following and then hit 'Enter':
conda create -p P:\<your username here>\<name of your new environment> –-channel=anaconda --channel=conda-forge nb_conda_kernels pandas numpy jupyterlab
- For example, if my username is 'leal' and I want to create an environment called 'mynewenv' in a folder called 'conda-envs', the command I would run would be:
conda create -p P:\leal\conda-envs\mynewenv –-channel=anaconda --channel=conda-forge nb_conda_kernels pandas numpy jupyterlab
- Wait a little while until the window asks you whether to proceed - hit 'y' on your keyboard and then press 'Enter'.
- Wait while your new environment is created and all requested packages are installed.
- You might get a pop-up saying, 'this app has been blocked by your system administrator, this is fine, and it all still worked. Just click 'Close' on the message.
- After your environment is created, you need to activate it by typing the following in the same command line window:
conda activate P:\<your username here>\<name of your new environment>
- So, if my username is 'leal' and I created an environment called 'mynewenv' in a folder called 'conda-envs', I would use the command:
conda activate P:\leal\conda-envs\mynewenv
- Congratulations, you can now move on to the next part of the guide.
Starting Jupyter
This assumes that you have done the initial setup and have an environment saved on your P: (pronounced 'P drive').
Suppose you've just completed the initial setup and have your new environment activated in an open command line window. In that case, you can skip steps 1-3.
- Log on to your SAIL desktop.
- Click on the Start menu (the little Windows icon on the bottom left) → Anaconda3 (64-bit) → Anaconda Prompt (Anaconda3). This will open a command line window with a line of text like:
- (base) C:\Users\<your username will be here>
- Activate your conda environment by typing the following in the same command line window:
conda activate P:\<your username here>\<name of your new environment>
- So, if my username is 'leal' and I created an environment called 'mynewenv' in a folder called 'conda-envs', I would use the command:
conda activate P:\leal\conda-envs\mynewenv
- You will know when the environment is activated because the window will show a line of text like:
- (P:\<your username>\<your environment name>) C:\Users\<your username>
- VERY IMPORTANT: Before starting Jupyter, we must ensure we're on the P: in the command line window. To do this, type the following into the window and press Enter:
P:
- Then type the following and press Enter:
cd <your username here>
- So if my username is 'leal', I would type:
cd leal
- (Optional) You might want to navigate to the specific folder in which you'll be working/saving this work, but that is out of the scope of this simple guide.
- We are now ready to start Jupyter. In the command line window, type and hit Enter with either of the following commands:
jupyter notebook
- This will give you the 'classic' Jupyter interface.
jupyter lab
- This gives you a more modern Jupyter interface.
- Jupyter will automatically open in a Microsoft Edge tab. You can navigate wherever you want to save your notebooks, create folders, make your notebooks, etc.
- You need to leave the Anaconda Prompt window open while you're using Jupyter.
- To ensure that you're using the correct environment kernel in Jupyter, you need to pay attention when creating notebooks.
- In the 'classic' interface:
- Click on 'New' in the top right.
- In the drop-down window that opens, make sure you choose the option called
Python \[conda env: <name of your conda env here>\]*
- In the modern interface:
- Under the 'Notebook' heading in the launcher tab, select the one with the name
Python \[conda env: <name of your conda env here>\]*
- Under the 'Notebook' heading in the launcher tab, select the one with the name
- In the 'classic' interface:
- When you're done and want to exit Jupyter, click on the 'Anaconda Prompt' window on the taskbar, click somewhere in the window, and press Ctrl+C twice.
- Please wait a few seconds; Jupyter should shut down, making it safe to close your notebook.
Installing packages
This assumes that you've completed the initial setup and have an environment saved on your P: .
Suppose you've just completed the initial setup and have your new environment activated in an open command line window. In that case, you can skip steps 1-3.
We strongly recommend users try installing from Anaconda sources for package installation. You should only use pip if a package isn't available from Anaconda channels.
- Log on to your SAIL desktop.
- Click on the Start menu (the little Windows icon on the bottom left) → Anaconda3 (64-bit) → Anaconda Prompt (Anaconda3). This will open a command line window with a line of text like:
- (base) C:\Users\<your username will be here>
- Activate your conda environment by typing the following in the same command line window:
conda activate P:\<your username here>\<name of your new environment>
- So, if my username is 'leal' and I created an environment called 'mynewenv' in a folder called 'conda-envs', I would use the command:
conda activate P:\leal\conda-envs\mynewenv
- You will know when the environment is activated because the window will show a line of text like:
- (P:\<your username>\<your environment name>) C:\Users\<your username>
- Outside your SAIL desktop, go to Google and search '<name of the package you want to install> anaconda'.
- For example, if I want to install the package 'recordlinkage', I would search on Google for 'recordlinkage anaconda'.
- Select the Google result from anaconda.org; this should take you directly to the Anaconda page for the package.
- On the page, there will be a command that tells you how to install it. Sticking with the recordlinkage example, the webpage shows me that the command to install is:
conda install -c conda-forge recordlinkage
- Go back to your SAIL desktop and type this installation command into your Anaconda Prompt window, hitting 'Enter'.
- Wait for Anaconda to ask you if you want to proceed - hit 'y' on your keyboard and then press 'Enter'.
- Your package is installed!
Instructions with explanations
Under construction