_drafts

Python JupyterLab and Kernels

Mini workshop.

  1. Intro
  2. Survey, click here!
  3. Discuss
  4. Environments and Kernels
  5. Notebooks

Conda

Package + environment management for Python (but can be used for other languages), conda docs.

Version and updates:

  • conda --version / conda info
  • conda update conda
  • conda update --all / conda update anaconda

Packages:

  • conda install [package]
  • conda remove [package]
  • conda list (all current packages + versions)

Keep in mind if you install something without using conda (i.e. pip), conda can’t update it.

Environments

XKCD python environment

  • conda create -n testenv
  • conda env list
  • conda activate testenv
  • conda deactivate
  • conda env remove -n testenv

Share:

  • conda env export --name myenv > myenv.yml
  • conda env create --file myenv.yml

Installing kernels

Python 2:

  • conda create -n py27 python=2.7
  • conda activate py27
  • conda install ipykernel
  • source deactivate

R:

  • conda create -n mro_env r-essentials mro-base

Julia:

  • Download Julia and install
  • which jupyter
  • JUPYTER=$(which jupyter) julia
  • using Pkg
  • Pkg.add("IJulia")

Kernels list

Anaconda Navigator is a GUI app to manage conda and install stuff…

  • Navigator docs
  • start on Linux: anaconda-navigator
  • create / manage / switch environments
  • manage packages, check versions
  • links to learning resources
  • launch apps in the correct environment

JupyterLab

  • It’s the future and it’s ready (news, blog). Notebook was designed around 2011–since then Python has been relatively stable, but web technology has changed rapidly… Jupyter Lab is an update using modern web technology,
  • If you have an up-to-date Anaconda install, it’s already installed
  • JupyterLab docs
  • fully backwards compatible (“Classic” Notebooks runs from the same server)
  • updated framework (built on JS)
  • more extensible
  • more IDE like (tabs and panes)
  • updated notebook features (drag & drop cells, collapse, context menu, more live preview formats and syntax highlighting)
  • code console (with notebook, text file, or codeblock in markdown > right-click to start console, shift+enter to run line or block)
  • Output view (right-click > “Create new view for output”)
  • conda install nb_conda
  • jupyter lab

Sharing notebooks

  • nbviewer (easy way to share a static rendered version of a notebook from GitHub)
  • binder (open a GitHub repo of notebooks in a temporary executable environment, docs)

Library resources