做数据科学离不开 Jupyter Notebook,但是显然 Jupyter Notebook 不单单是为了 Python 而设置(但是离开 Python 显然也很不方便)。
Ruby 相比于 Python 安装较为复杂。我们可以用 Juptyer Notebook 安装 Ruby Kernel,降低入门的难度。
安装软件
- python
- jupyter
- Ruby
- iruby
下面以 Ubuntu 系统为例
通过 miniconda 安装 python
#!/usr/bin/bash
set -e
wget "https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh" -O ~/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/miniconda
~/miniconda/bin/conda init $(echo $SHELL | awk -F '/' '{print $NF}')
echo 'Successfully installed miniconda...'
echo -n 'Conda version: '
~/miniconda/bin/conda --version
echo -e '\n'
exec bash
安装 jupyter
pip3 install jupyter
安装 ruby
rbenv install 2.7.4
安装 iruby
gem install iruby
启动 jupyter
jupyter notebook
如下图所示,我们可以选择 ruby kernel。
如果你喜欢在 VS Code 中编辑代码,可以使用 VS Code 直接打开 .ipynb 文件。如下图所示:
总结
使用 jupyter 学习 Ruby 应该是最简单的了,唯一遗憾的就是环境搭建略嫌麻烦。