做数据科学离不开 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 应该是最简单的了,唯一遗憾的就是环境搭建略嫌麻烦。
使用JupyterNotebook轻松学习Ruby
这篇博客介绍了如何在Ubuntu系统中利用Miniconda安装Python,然后通过JupyterNotebook安装RubyKernel,以降低Ruby的入门难度。详细步骤包括安装miniconda、jupyter、Ruby和iruby。最后,可以通过Jupyter选择Ruby kernel进行编程,或者在VSCode中编辑.ipynb文件。虽然环境搭建稍显繁琐,但这种方法为学习Ruby提供了便利。
4291

被折叠的 条评论
为什么被折叠?



