Skip to content

Instantly share code, notes, and snippets.

@Zsailer
Last active April 22, 2021 15:29
Show Gist options
  • Save Zsailer/e935c3ee57fbd31ab0a67800a7b2fb58 to your computer and use it in GitHub Desktop.
Save Zsailer/e935c3ee57fbd31ab0a67800a7b2fb58 to your computer and use it in GitHub Desktop.
Managing your Jupyter development workflow

Managing your Jupyter development workflow

The following directions explain how to setup your Jupyter development environment. The goal is to isolate each one of your projects in their own "virtual environment" (a.k.a. conda environment), so you can easily switch between projects without contaminating your installations, dependencies, etc.

Table of Contents

Setup

  1. Install Miniconda according to their instructions here.
  2. Create a projects/ folder.

Starting a project

  1. Create a folder for your extension or project inside projects/
mkdir my_extension
  1. Create a conda environment for that project (and install pip).
conda create -n my_extension pip
  1. Switch into that environment. You'll need to be in this environment to install the development versions of the packages you're work on (see steps 6-8).
conda activate my_extension
  1. (Optional) Install dependencies you make need, that don't need a development version.
pip install numpy    
  1. Navigate to that extension's folder.
cd my_extension
  1. Clone any projects you will need for development.
git clone https://www.github.com/jupyterlab/jupyterlab
git clone https://www.github.com/my_username/my_extension
  1. Create and switch into development branches in each repo. Example:
# Change into jupyterlab repo.
cd jupyterlab

# Create branch and switch to it.
git checkout -b my_feature

# Change into my_extension repo.
cd ../my_extension

# Create branch and switch to it.
git checkout -b my_feature
  1. Install those packages (in that conda environment) using the development installation instructions.
  2. Open your favorite editor (I use VSCode) inside your project folder.

You'll see all the libraries you'll use for development in your current workspace. When you test your project, it will only use the libraries+branches you installed in that environment.

Returning to a project

  1. Navigate to your project
cd /path/to/projects/my_extension.
  1. Switch to the conda environment for that project
conda activate my_extension
  1. Open your favorite editor (I use VSCode) inside your project folder.

Helpful commands

List your conda environments:

conda env list

Leave an environment

conda deactivate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment