Python/R/Julia @ iPython/Jupyter notebook @ Ubuntu 20.04

习惯在 iPython notebook里写实验性的代码(其实Jupyter notebook)。看到 www.jupyter.org 上说可以用其他语言,包括R、Julia、C++、Scheme、Ruby等。本人对R和Julia比较感兴趣,就在 Ubuntu 20.04@RaspberryPi 4B上试了一下。

Python @ iPython notebook

这个最简单

$ sudo apt install ipython3 python3-notebook  # 安装iPython notebook
$ ipython3 notebook password                  # 设定登陆密码
$ screen -dmS note
$ screen -r note
$ ipython3 notebook --ip=0.0.0.0 --port=8080 --no-browser
$ Ctrl+a Ctrl+d #以上放在一个screen虚拟终端里跑

R @ iPython notebook

这个有点麻烦,但是Ubuntu已经有对应的软件包。

$ sudo apt install r-base #R基础包,会关联不少包
$ sudo apt install r-cran-irkernel # 也会关联一大堆包
$ sudo R
R> library(IRkernel)
R> IRkernel::installspec(user = FALSE) # 安装到全局,而不是用户
Error in IRkernel::installspec(user = FALSE) :
  jupyter-client has to be installed but “jupyter kernelspec --version” exited with code 1.

操作最后出现错误,但是使用无问题。apt install jupyter-client 

Julia @ iPython notebook

Ubuntu 20.04封装的Julia包不多。需要官方源之外的支持。

$ sudo julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.4.1
 _/ |\__'_|_|_|\__'_|  |  Ubuntu ⛬  julia/1.4.1+dfsg-1
|__/                   |

julia> #按 ] 进入pkg模式,Ctrl+c退回

(@v1.4) pkg> add IJulia # 参考https://github.com/JuliaLang/IJulia.jl

然后重新启动 iPython notebook 就可以建立Python/R/Julia不同的notebook了。

Stata @ iPython notebook

没有成功。原因很显然。

root@Julia:~# pip3 install stata_kernel
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting stata_kernel
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b9/b1/2dffa47989d0777fe49c655dd9ea5d62acbfb887f84eff779974b11020b9/stata_kernel-1.12.2.tar.gz (90 kB)
     |████████████████████████████████| 90 kB 473 kB/s
Requirement already satisfied: IPython>=6.5.0 in /usr/lib/python3/dist-packages (from stata_kernel) (7.13.0)
Requirement already satisfied: beautifulsoup4>=4.6.3 in /usr/lib/python3/dist-packages (from stata_kernel) (4.8.2)
Requirement already satisfied: ipykernel>=4.8.2 in /usr/lib/python3/dist-packages (from stata_kernel) (5.2.0)
Requirement already satisfied: jupyter_client>=5.2.3 in /usr/lib/python3/dist-packages (from stata_kernel) (6.1.2)
Requirement already satisfied: packaging>=17.1 in /usr/lib/python3/dist-packages (from stata_kernel) (20.3)
Requirement already satisfied: pandas>=0.22.0 in /usr/lib/python3/dist-packages (from stata_kernel) (0.25.3)
Requirement already satisfied: pexpect>=4.6.0 in /usr/lib/python3/dist-packages (from stata_kernel) (4.6.0)
Requirement already satisfied: pillow>=5.2.0 in /usr/lib/python3/dist-packages (from stata_kernel) (7.0.0)
Requirement already satisfied: pygments>=2.2.0 in /usr/lib/python3/dist-packages (from stata_kernel) (2.3.1)
Requirement already satisfied: requests>=2.19.1 in /usr/lib/python3/dist-packages (from stata_kernel) (2.22.0)
Building wheels for collected packages: stata-kernel
  Building wheel for stata-kernel (setup.py) ... done
  Created wheel for stata-kernel: filename=stata_kernel-1.12.2-py3-none-any.whl size=89548 sha256=692a182dbb256cf245da15f17cd39ec3a290fa072f945e2d1da2e666e233e857
  Stored in directory: /root/.cache/pip/wheels/d6/30/a0/c4c88519b498f8f2965f6983b4b86a69f07bee00c7d35abb16
Successfully built stata-kernel
Installing collected packages: stata-kernel
Successfully installed stata-kernel-1.12.2
root@Julia:~# python -m stata_kernel.install
Cannot import kernel
Installing Jupyter kernel spec
WARNING: Could not find Stata path.
Refer to the documentation to see how to set it manually:

https://kylebarron.dev/stata_kernel/using_stata_kernel/configuration

配置代码自动提示 

$ sudo pip3 install jupyter_contrib_nbextensions
$ sudo jupyter contrib nbextension install
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值