Skip to content

Instantly share code, notes, and snippets.

@patoroco
Last active November 1, 2022 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patoroco/f9db6e2e98bbb4e91d5998c7c90d2bb0 to your computer and use it in GitHub Desktop.
Save patoroco/f9db6e2e98bbb4e91d5998c7c90d2bb0 to your computer and use it in GitHub Desktop.
Setup to get jupyter running in local using a virtualenv (created with pipenv)

Setup for running the following steps

export PROJECT_NAME=the_name_of_the_project
export PY_VERSION=3.10.5

mkdir $PROJECT_NAME
cd $PROJECT_NAME

Creating the virtualenv

pyenv local $PY_VERSION

pipenv install --python $PY_VERSION

git init
git add .
git commit -m "First commit for '$PROJECT_NAME'"

# Activate the virtualenv
pipenv shell

Installing dependencies

# Option 1: just installing for testing the package. It will not be added to the Pipfile
pip install requests

# Option 2: installing via pipenv for development -> it will be included in the Pipfile
pipenv install --dev requests

Installing jupyther & kernel

pipenv install jupyter ipykernel

# kernel for this virtualenv
python -m ipykernel install --user --name $PROJECT_NAME --display-name "$PROJECT_NAME - `python --version`"

Run jupyther

jupyter notebook

Cleanup all the stuff

# uninstall the kernel
jupyter kernelspec uninstall $PROJECT_NAME

pipenv --rm

Miscelanious

# list all the availables kernels for Jupyter
jupyter kernelspec list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment