Jupyter Notebook

Installing Jupyter notebook

Jupyter notebook is a cross platform notebook that can run code for statistical analysis. To install it on your computer (Mac OSX or Windows) use the following instructions:

  1. Install Python 3 on your computer: https://www.python.org/downloads/. There are two versions of Python (2 and 3), each with different releases. Make sure you select the correct version: 3.5 (ie 3.5.6) or higher is recommended (use a stable version). Mac OSX comes with Python 2 software installed. However, it is recommended to use Python 3 and install Python from the Python website.
  2. Install Jupyter on your computer: http://jupyter.org/install. Jupyter can be installed using pip (Python’s package manager) from the computer’s shell / terminal. Just copy and paste the code as described on the Jupyter website. If more than one version of python are installed on your computer, use pip3 or pip3.8 to install for a specific version of python. Without specification, pip will install for the default python installation (you can find out the default python version by typing python in the shell and see what version of python starts up).
  3. Install R from Cran https://cran.r-project.org/
  4. Install the R Kernel from https://irkernel.github.io/installation/
    • Mac OSX users: do this from terminal; not the R app !!!!
      1. Open terminal (or commander from windows) and type r followed by ‘Enter’
      2. In R copy and paste the following code (each line followed by ‘Enter’)
        1. packages(c(‘repr’, ‘IRdisplay’, ‘evaluate’, ‘crayon’, ‘pbdZMQ’, ‘devtools’, ‘uuid’, ‘digest’))
        2. devtools::install_github(‘IRkernel/IRkernel’)
        3. IRkernel::installspec()
        4. To quit R, type q(), followed by ‘Enter’
      3. If following a software update notebook fails to work; reinstall as above:
        1. Make sure Xcode is installed
        2. In terminal enter to install / update the command-line tools:
        3. xcode-select –install
  5.  Open terminal (Mac) or cmd (Windows) and enter:
  • ‘jupyter notebook’ followed by ‘Enter’
  • Notebook should open in a web browser
  • Manoeuvre to your file or create a new one
  • You can share files in DropBox

Statistics course participants, open the introduction.ipynb notebook from your DropBox

Sometimes, the quotation marks ‘ or ” don’t copy and paste correctly  and they may need to be re-entered manually if an error occurs.

Windows  Users

When Python 3 is installed, it can be opened by clicking on the relevant icon in your applications folder. However, for Jupyter notebook to work, you need to open Python 3 from the command prompt.

You can find the command prompt under ‘Windows System’. In the command prompt window, enter ‘python’. If you used the default installation of Python, you will get an error message. It is necessary to add the location of the python program to the path (where the computer searches for known programs).

To add Python to the path, go to the control panel (under Windows System) and search for ‘Environment’ in the search field (top right hand corner).

2019-10-20 (2)
Select ‘Edit the system environment variables’ and then click on the button ‘Environment Variables…’ in the Advanced tab.

environment_2

This should show you a screen with the Environment Variables for your user account as well as the system. Select ‘Path’ from your user account and click on ‘Edit’.path_2

path_3

This will take you to ‘Edit environment variable’ screen that will allow you to add Python to the path (already shown here). path_1

Select ‘New’ and enter the location of your Python path.

This should be something like (as shown above):

C:\Users\your_user_account_name\AppData\Local\Programs\Python\Python37-32\

You can check the path by looking into the Users, your_user_account_name, AppData, Local, Programs, Python, Python37-32 folder. If you click on the folder icon in the title bar, the full path comes up and you can copy and paste this into the path.

Once Python has been added to the path, you should be able to open Python by typing ‘python’ in the command prompt window:

2019-10-20

You can exit Python by typing ‘exit()’ followed by enter:

2019-10-20 (1)

You should now be able to use ‘pip install’ as per manual. If you have more than one version of Python installed; use ‘pip3 install’

When you install the Jupyter notebook package, it will give you a warning that the Scripts are not in the path. You can add the Scripts to the path using the same method as above. Just enter an other path location, which is the same as the Python path, but is followed by \Scripts:

path_1

The rest of the installation should be according to the manual.