29

Jupyter 集成 go 内核

 4 years ago
source link: https://studygolang.com/articles/25014
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

基于 gophernotes .

依赖

ZeroMQ的安装

# centos
yum install zeromq

其他系统,见 https://zeromq.org/download/#linux

安装 gophernotes

以centos为例

$ go get -u github.com/gopherdata/gophernotes
$ mkdir -p ~/.local/share/jupyter/kernels/gophernotes
$ cp $GOPATH/src/github.com/gopherdata/gophernotes/kernel/* ~/.local/share/jupyter/kernels/gophernotes
  1. 服务器 go get 有翻墙问题的,可以参考 https://shockerli.net/post/go-get-golang-org-x-solution/ ,通过修改 GOPROXY 环境变量 的方式解决。
  2. 命令目的是:在jupyter内核新建gophernotes的文件
  3. cp 的源目录,需要你自己确定 gophernotes package 被安装到哪个位置。然后检查 ~/.local/share/jupyter\kernels\gophernotes\kernel.json 文件 的 "argv" 数组的 gophernotes 路径是否正确,如 "/root/go/bin/gophernotes"

gophernotes 添加至 PATH ,执行 gophernotes 命令,得到如下输出,说明安装成功。

$ gophernotes
2017/09/20 10:33:12 Need a command line argument specifying the connection file.

最后重启 Jupyter 完成。

supervisor

如果你是用supervisor帮你管理jupyter的进程,那你需要将go相关的环境变量写入进程的.ini配置文件。举例:

[program:jupyter-notebook]
...
...
environment=ENV="dev",PATH="/usr/local/go/bin:/root/go/bin:/usr/bin:$PATH",GOPROXY="https://goproxy.cn",GO111MODULE="on"

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK