3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Pipenv管理下のJupyter NotebookプロジェクトにRuby kernelをBundlerで入れる

Posted at

グローバルな環境にPython, Pipenv, Ruby, Bundlerはインストール済みと仮定します。

動作確認済みのバージョンは以下

$ python --version
Python 3.6.2

$ pipenv --version                       
pipenv, version 2018.05.18

$  ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]

$ bundle -v
Bundler version 1.16.2

プロジェクト開始

$ mkdir someProject
$ cd someProject

Pythonパッケージインストール

$ pipenv install jupyter

Rubyパッケージインストール

$ bundle init
Gemfile
# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem 'cztop'
gem 'iruby'
gem 'rbczmq'

$ bundle install --path=vendor/bundle

Jupyter NotebookにRuby kernelを登録

次のコマンドが唯一のポイントです。

$ pipenv run bundle exec iruby resister

pipenv runしないとipythonコマンドが見つからないと怒られます。

間違ったコマンド
$ bundle exec iruby resister

bundler: failed to load command: iruby (path/to/someProject/vendor/bundle/ruby/2.5.0/bin/iruby)
Errno::ENOENT: No such file or directory - ipython

設定ファイル変更

前述のコマンドで~/.ipythonディレクトリが作られますので、以下のようにファイルを変更します。

display_nameはお好みで変更可)

~/.ipython/kernels/ruby/kernel.json
{
	"argv": [
		"pipenv",
        "run",
        "bundle",
        "exec",
        "iruby",
		"kernel",
		"{connection_file}"
	],
	"display_name": "Ruby 2.5.1",
	"language": "ruby"
}

実行

$ pipenv run jupyter notebook

New▼からRubyが選べる!しあわせ!

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?