ENGR 1330 Computational Thinking with Data Science

Last GitHub Commit Date: 19 January 2021

Special Script Blocks

Building the JupyterLab (iPython) programming environment

The laboratory and homeworks are to be accomplished using JupyterLab/iPython notebooks.
The recomended integrated development environment (IDE) is called Anaconda (www.anaconda.com).

The three primary means to get a working JupyterLab/iPython environment are shown below

Installing Anaconda on a Machine you own (i.e. your laptop)

Install Anaconda on Windows 10 Machine

The video https://youtu.be/xBfoK6jDpTw shows an install onto a Windows machine.

Install Anaconda on MacOS Machine

The video https://youtu.be/y26RCKWlv7M shows a step-by-step install onto a Macintosh (Catalina OS) machine.

Installing Anaconda on a Cloud-Hosted Machine

Install Anaconda on AWS Windows Instance

The video https://youtu.be/s8CJKq2Rvgg shows a step-by-step install onto a Windows machine hosted on Amazon Web Services (cloud hosted).

Installing JupyterHub on a non-x86-64 chipset (i.e. Raspberry Pi, Hardkernel, ... )

If you have a machine that does not use the x86-64 chipset (so not an Intel or not AMD), then you have extra bonus problems. Compared to the above its a monumental pain. The notes below follow https://jupyterhub.readthedocs.io/en/stable/installation-guide-hard.html

Here's what worked for me:

  1. Build an OS (Raspian or Ubuntu)
    1. initial updates
      • sudo apt-get update
      • sudo apt-get upgrade
      • sudo apt-get dist-upgrade
    2. change hostname (optional)
      • sudo hostnamectl set-hostname atomickitty.arm64
    3. create users (also optional, but suggest at least one non-sudo)
      • sudo useradd -m -d /home/polaris -s /bin/bash polaris
      • sudo useradd -m -d /home/antares -s /bin/bash antares
      • sudo useradd -m -d /home/aquarius -s /bin/bash aquarius
    4. set passwords
      • polaris == password
      • antares == password
      • aquarius == password
    5. install and configure apache (or nginx). Optional but useful to secure the proxy
      • sudo apt install apache2
      • sudo systemctl status apache2
      • sudo systemctl stop apache2
    6. install and configure JupyterHub
      • sudo apt install -y python3-pip
      • sudo apt install -y build-essential libssl-dev libffi-dev python3-dev
      • sudo apt-get install python3-venv
      • sudo python3 -m venv /opt/jupyterhub/
      • sudo apt install nodejs npm
      • sudo npm install -g configurable-http-proxy
      • sudo /opt/jupyterhub/bin/python3 -m pip install wheel
      • sudo /opt/jupyterhub/bin/python3 -m pip install jupyterhub jupyterlab
      • sudo /opt/jupyterhub/bin/python3 -m pip install ipywidgets
      • sudo mkdir -p /opt/jupyterhub/etc/jupyterhub/
      • cd /opt/jupyterhub/etc/jupyterhub/
      • sudo /opt/jupyterhub/bin/jupyterhub --generate-config
  2. Configure the JupyterHub

    1. Edit the config file just created and make change to "c.Spawner.default_url = '/lab'"
    2. Set up as a system service
      • sudo mkdir -p /opt/jupyterhub/etc/systemd
      • sudo nano /opt/jupyterhub/etc/systemd/jupyterhub.service
    3. Edit the jupyterhub.service file just opened in nano

      • ADD:

[Unit]\ Description=JupyterHub\ After=syslog.target network.target

[Service]\ User=root\ Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/jupyterhub/bin"\ ExecStart=/opt/jupyterhub/bin/jupyterhub -f /opt/jupyterhub/etc/jupyterhub/jupyterhub_config.py

[Install]\ WantedBy=multi-user.target

  1. Link the service definition file to system;enable the service

    • sudo ln -s /opt/jupyterhub/etc/systemd/jupyterhub.service /etc/systemd/system/jupyterhub.service
    • sudo systemctl daemon-reload
    • sudo systemctl enable jupyterhub.service
    • sudo systemctl status jupyterhub.service
    • sudo systemctl start jupyterhub.service
  2. enable https

    1. sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt
    2. SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
    3. SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
  3. Restart everything

    • sudo systemctl restart apache2.service
    • sudo systemctl restart jupyterhub.service

If you like to tinker, you would have a functioning JupyterHub that you can share. The above also works for x86-64 linux builds; although if you are on x86-64, I would just use the anaconda for linux files.