跳转到主要内容

从虚拟环境中创建jupyter内核

项目描述

Build Status Coverage Status

Callisto

Jupyter的第四个伽利略卫星

一个命令行工具,可以从虚拟环境中创建Jupyter内核。

安装

Callisto可以从PyPI安装

pip install callisto

测试过python 2.7, 3.4, 3.5, 3.6。

基本用法。

典型用法是在虚拟环境中激活它

$  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服务器现在将有一个名为venv的内核选项。

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

命名内核。

您也可以给内核一个更描述性的名称

(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服务器现在将有一个名为venvpete的内核选项。

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

删除内核。

有时您可能想整理一下内核。

(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服务器将不再有名为venv的内核。

缺乏勇气。

Callisto并不试图过于聪明。

(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!

查看现有内核。

如果您忘记了有关内核信息的说明性消息,您可以在以后查看它。

$  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": {}
}

调整PYTHONPATH

对于隔离的内核,您可能希望从单个目录运行所有notebooks,但使用来自项目目录的代码。

(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.

现在pete内核将能够从文件夹/Users/colin/projects/pete导入。

项目详情


下载文件

下载适用于您的平台文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

本版本没有提供源分发文件。请参阅有关生成分发归档的教程。

构建的分发

callisto-0.7-py2.py3-none-any.whl (7.1 kB 查看哈希值)

上传时间 Python 2 Python 3

支持