Skip to main content

Create jupyter kernels from virtual environments

Project description

Build Status Coverage Status

Callisto

The fourth Galilean moon of Jupyter.

A command line utility to create kernels in Jupyter from virtual environments.

Installation

Callisto may be installed from pypi:

pip install callisto

Tested against python 2.7, 3.4, 3.5, 3.6.

Basic Usage.

Typical use is to just activate it inside a virtual environment:

$  virtualenv venv
...
$  source venv/bin/activate
(venv) $  callisto
Successfully installed a new jupyter kernel "venv":
{
  "env": {},
  "language": "python",
  "display_name": "venv",
  "argv": [
    "/Users/colin/venv/bin/python",
    "-m",
    "ipykernel",
    "-f",
    "{connection_file}"
  ]
}
See /Users/colin/Library/Jupyter/kernels/venv/kernel.json to edit.

Jupyter servers will now have an option for a kernel called venv.

https://colindcarroll.com/img/venv.png

Naming the kernel.

You may also give kernels a more descriptive name:

(venv) $  callisto -n pete
Successfully installed a new jupyter kernel "pete":
{
  "env": {},
  "display_name": "pete",
  "argv": [
    "/Users/colin/venv/bin/python",
    "-m",
    "ipykernel",
    "-f",
    "{connection_file}"
  ],
  "language": "python"
}
See /Users/colin/Library/Jupyter/kernels/pete/kernel.json to edit.

Jupyter servers will now have an option for a kernel called venv, and pete.

https://colindcarroll.com/img/venv_and_pete.png

Deleting kernels.

Sometimes you may want to tidy kernels up a bit.

(venv) $  callisto -d
Deleted jupyter kernel "venv" from /Users/colin/Library/Jupyter/kernels/venv/kernel.json:
{
  "argv": [
    "/Users/colin/venv/bin/python",
    "-m",
    "ipykernel",
    "-f",
    "{connection_file}"
  ],
  "env": {},
  "language": "python",
  "display_name": "venv"
}

Jupyter servers will no longer have a kernel named venv.

Lacking courage.

Callisto doesn’t try to be too clever.

(venv) $  deactivate

$  callisto
Usage: callisto [OPTIONS]

Error: The environment variable VIRTUAL_ENV is not set (usually this is set
automatically activating a virtualenv).  Please make sure you are in a
virtual environment!

Viewing existing kernels.

If you forgot the informative message about the kernel information, you can see it later.

$  source venv/bin/activate

(venv) $  callisto --list
No kernel found at /Users/colin/Library/Jupyter/kernels/venv/kernel.json

(venv) $  callisto -l --name pete
Found kernel "pete" at /Users/colin/Library/Jupyter/kernels/pete/kernel.json:
{
  "display_name": "pete",
  "language": "python",
  "argv": [
    "/Users/colin/venv/bin/python",
    "-m",
    "ipykernel",
    "-f",
    "{connection_file}"
  ],
  "env": {}
}

Adjusting the PYTHONPATH.

With isolated kernels, you may wish to run all your notebooks from a single directory, but using code from the project directories.

(venv) $  callisto -n pete --path=$(pwd)
Successfully installed a new jupyter kernel "pete":

{
  "argv": [
    "/Users/colin/venv/bin/python",
    "-m",
    "ipykernel",
    "-f",
    "{connection_file}"
  ],
  "language": "python",
  "env": {
    "PYTHONPATH": "/Users/colin/projects/pete:PYTHONPATH"
  },
  "display_name": "pete"
}
See /Users/colin/Library/Jupyter/kernels/pete/kernel.json to edit.

Now the pete kernel will be able to import from the folder /Users/colin/projects/pete.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

callisto-0.5.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

callisto-0.5-py2.py3-none-any.whl (7.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file callisto-0.5.tar.gz.

File metadata

  • Download URL: callisto-0.5.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for callisto-0.5.tar.gz
Algorithm Hash digest
SHA256 e1217337276f02e4fa6f09a209bf94c80f32439b39717ad12fcfc9f682f5930c
MD5 0545184a0a52fb3798166ad84943f3ae
BLAKE2b-256 979a3939ef80d481d7ad4ac443f3fa368dbbe92938cc6a1e2cd0c770db8394ca

See more details on using hashes here.

File details

Details for the file callisto-0.5-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for callisto-0.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 41157fbe831ef9fbfef32eac3a500d16633d0a6615913f9c02660952a9daddbb
MD5 9e820894a5469cfc934b048be7ab72e3
BLAKE2b-256 cc7001774fd4217aeb0f22244223ec159d526d08024904e8b383602003d5bbc3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page