Course materials for the CodeFirstGirls Sheffield Introduction to Python Course
To run the Jupyter Notebook slides, you need:
- Python 3
- The
jupyter
Python package - The
RISE
Python package
Install Python 3 with the link above. Then, open a terminal and run the following commands to install the jupyter
and RISE
package:
pip install jupyter RISE
If you also have Python 2 installed on your computer (i.e. if you are working on a Mac/Linux machine), you may have to replace pip
with
pip3
in the command above.
In the terminal, change to the directory containing the Jupyter Notebook slides, then run the following commands to start the Jupyter Notebook server needed to run the slides:
jupyter notebook
Alternatively, if your machine can run Docker (Windows 10 Pro, MacOS or any Linux distro), you can run the Jupyter Notebook server inside a Docker container.
To begin, install Docker and the Docker Compose command line tool. If you are on Windows or MacOS, Docker Compose will have already come with your Docker installation.
Then, at the root of the repository, type this single command to start the Jupyter Notebook server:
docker-compose up
You should see output similar to the following:
Starting jupyter-notebook ... done
Attaching to jupyter-notebook
jupyter-notebook | Executing the command: jupyter notebook
jupyter-notebook | [I 20:38:44.343 NotebookApp] JupyterLab extension loaded from /opt/conda/lib/python3.7/site-packages/jupyterlab
jupyter-notebook | [I 20:38:44.343 NotebookApp] JupyterLab application directory is /opt/conda/share/jupyter/lab
jupyter-notebook | [I 20:38:45.348 NotebookApp] Serving notebooks from local directory: /home/jovyan
jupyter-notebook | [I 20:38:45.348 NotebookApp] The Jupyter Notebook is running at:
jupyter-notebook | [I 20:38:45.349 NotebookApp] http://47e3a7c93868:8888/?token=c5abd1bcdfbb9f70d26eed5a045eb3a58dd7c1d9e8627b29
jupyter-notebook | [I 20:38:45.349 NotebookApp] or http://127.0.0.1:8888/?token=c5abd1bcdfbb9f70d26eed5a045eb3a58dd7c1d9e8627b29
jupyter-notebook | [I 20:38:45.349 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
jupyter-notebook | [C 20:38:45.354 NotebookApp]
jupyter-notebook |
jupyter-notebook | To access the notebook, open this file in a browser:
jupyter-notebook | file:///home/jovyan/.local/share/jupyter/runtime/nbserver-6-open.html
jupyter-notebook | Or copy and paste one of these URLs:
jupyter-notebook | http://47e3a7c93868:8888/?token=c5abd1bcdfbb9f70d26eed5a045eb3a58dd7c1d9e8627b29
jupyter-notebook | or http://127.0.0.1:8888/?token=c5abd1bcdfbb9f70d26eed5a045eb3a58dd7c1d9e8627b29
Unlike Method 1 which opens a browser automatically, you need to copy the URL beginning with http://127.0.0.1:8888
in your browser instead
to see the same Jupyter user interface.
Using nbconvert (from https://rise.readthedocs.io/en/stable/exportpdf.html)
Generate the slides and serve them using nbconvert:
jupyter nbconvert --to slides your_talk.ipynb --post serve
It opens up a webpage in the browser at http://127.0.0.1:8000/your_talk.slides.html#/
Add ?print-pdf to the query string as http://127.0.0.1:8000/your_talk.slides.html?print-pdf Note that you need to remove the # at the end. The page will render the slides vertically.
Save to PDF in Chrome using the print option:
Open the in-browser print dialog (Cmd/Ctrl + P).
Change the Destination setting to Save as PDF.
Change the Layout to Landscape.
Change the Margins to None.
Enable the Background graphics option.
Click Save.
Download pandoc & wkhtmltopdf (need to add wkgtmltopdf to path)
navigate to folder where the file is located
pandoc -t html --css stylesheet.css {filename}.md -o {output filename}.pdf -V margin-top=20 -V margin-left=20 -V margin-right=20 -V margin-bottom=20