Using Jupyter for Classroom

OSC provides an isolated and custom Jupyter environment for each classroom project that requires Jupyter Notebook or JupyterLab. The interface can be accessed at Before using this interface, please apply for a classroom project account that is unique for the course.  More details on the classroom project can be in our classroom project guide. The custom Jupyter environment for the course will be tied to this project ID. Please inform us if you have additional requirements for storage. Once we get the information, we will provide you a course ID and add your course to the server with the class module created using the course ID.

Before testing the module, please follow the instructions below to create a Jupyter environment for class and send us with the full path of the environment. Once we update the server, you can login to to test the Jupyter environment. After login, you will see several Apps listed. Pick Jupyter App and that will take you to the Jupyter Job submission page. Please pick your course from the drop-down menu under the Class materials and the number of hours and cores needed.

Set up a Jupyter environment for class

A Jupyter environment for class is created using Python 3 venv module, and is shared with students. The environment created is an isolated Python environment, meaning that system Python packages and user's local packages become inaccessible when you switch to (activate) this environment. It is easy for PI to manage packages dedicated for class. 

PI can create a Jupyter environment in either own home or project space.

Using project space (recommended)

If project space is used, e.g. /fs/ess/projectID/courseID/jupyter,  no permission change is required because students would be added into the project.

Using home space 
If home space is used, PI must make the home directory accessed by students.

For example, a Jupyter environment is created at $HOME/osc_classes/courseID/jupyter. and your class project ID is PAS1234. Then add execution permission to $HOME and the sub-directories,

mkdir -p $HOME/osc_classes/courseID/jupyter
nfs4_setfacl -a $HOME
nfs4_setfacl -a $HOME/osc_classes

Create a virtual environment

Login to Owens or Pitzer at OSC, and in a terminal (see Getting Connected). Assuming that the course ID is  PHYSIC6820, run the following commands to create a virtual environment:

module reset
python3 -m venv --without-pip --prompt "PHYSIC6820" /PATH/TO/JUPYTER/VENV

where /PATH/TO/JUPYTER/VENV can be one of examples above or any place you prefer.

Initiate the environment

After createing the virtual environment, switch to (activate) it and install Jupyter and any python packages for class

source /PATH/TO/JUPYTER/VENV/bin/activate   # use activate.csh if you are in a C shell
(PHYSIC6820)$ curl |python
(PHYSIC6820)$ pip install jupyterlab jupyter-console qtconsole ipywidgets
(PHYSIC6820)$ pip install pkg1 pkg2 ...
(PHYSIC6820)$ deactivate

The command deactivate is not required if you continue testing and using packages installed in the Jupyter environment. 

Once PI complete creating the environment, please update us with the full path of the environment in order to complete the server setup.

Install more packages

PI can install more package anytime in a terminal 

source /PATH/TO/JUPYTER/VENV/bin/activate # use activate.csh if you use C shell
(PHYSIC6820)$ pip install pkg1 pkg2 ...
(PHYSIC6820)$ deactivate

or in a Jupyter Notebook during the classScreen Shot 2020-08-20 at 10.09.48 AM.png

Enable PDF exporter

To export a notebook as PDF file, it needs complete Tex environment and Pandoc binary (not pandoc python package). The former is taken care of by our system module now. For the latter PI needs to install pandoc in a Jupyter environment:

tar xf pandoc-2.10.1-linux-amd64.tar.gz -C $VIRTUAL_ENV --strip=1

Enable local package access (optional)

By default this Jupyter environment is an isolated Python environment. Anyone launches python from this environment can only access packages installed inside unless PYTHONPATH is used. PI can change it by setting include-system-site-packages = true in /PATH/TO/JUPYTER/VENV/pyvenv.cfg. This will allows students to access packages in home directory ~/.local/lib/pythonx.x/site-packages ,and install packages via pip install –user.


When a class session starts, we create a classroom workspace under PI's and students' home space: $HOME/osc_classes/courseID, and launch Jupyter at the workspace. The root /  will appear in the landing page (Files) but everything can be found in $HOME/osc_classes/courseID at OSC.

Shared Access

PI can share class material from home or project space with students. For example, you have a directory called "modules" in project space /fs/ess/projectID/courseID/modules  (source) that contains the class material. When a student launch a Jupyter session, the diretory will be copied to the student's worksapce $HOME/osc_classes/courseID (destinatation). The student will see the directory modules at the landing page:

Screen Shot 2020-08-17 at 11.02.26 AM.png

PI can add files to the material source directory. New files will be copied to the destination everytime when a new Jupyter  session starts. 

Once you decide the location for the material, please update us with the full path of the material directory.