jupyter with R

本文详细描述了如何在Anaconda环境下,通过JupyterNotebook和RStudio安装必要的R包(如repr,IRdisplay等),并指导用户如何通过devtools从GitHub克隆IRkernel包,完成R在Jupyter中的支持设置。
摘要由CSDN通过智能技术生成

准备工作:

anaconda

jupyter

R/Rstudio

安装教程

Rstudio的左下角console输入代码:

install.packages(c('repr', 'IRdisplay', 'evaluate', 'crayon', 'pbdZMQ', 'devtools', 'uuid', 'digest'))
devtools::install_github('IRkernel/IRkernel')

输出结果1:

> install.packages(c('repr', 'IRdisplay', 'evaluate', 'crayon', 'pbdZMQ', 'devtools', 'uuid', 'digest'))
trying URL 'https://mirrors.sjtug.sjtu.edu.cn/cran/bin/windows/contrib/4.2/repr_1.1.6.zip'
Content type 'application/zip' length 124135 bytes (121 KB)
downloaded 121 KB

trying URL 'https://mirrors.sjtug.sjtu.edu.cn/cran/bin/windows/contrib/4.2/IRdisplay_1.1.zip'
Content type 'application/zip' length 34059 bytes (33 KB)
downloaded 33 KB

trying URL 'https://mirrors.sjtug.sjtu.edu.cn/cran/bin/windows/contrib/4.2/evaluate_0.21.zip'
Content type 'application/zip' length 82908 bytes (80 KB)
downloaded 80 KB

trying URL 'https://mirrors.sjtug.sjtu.edu.cn/cran/bin/windows/contrib/4.2/crayon_1.5.2.zip'
Content type 'application/zip' length 162786 bytes (158 KB)
downloaded 158 KB

trying URL 'https://mirrors.sjtug.sjtu.edu.cn/cran/bin/windows/contrib/4.2/pbdZMQ_0.3-10.zip'
Content type 'application/zip' length 992827 bytes (969 KB)
downloaded 969 KB

trying URL 'https://mirrors.sjtug.sjtu.edu.cn/cran/bin/windows/contrib/4.2/devtools_2.4.5.zip'
Content type 'application/zip' length 436903 bytes (426 KB)
downloaded 426 KB

trying URL 'https://mirrors.sjtug.sjtu.edu.cn/cran/bin/windows/contrib/4.2/uuid_1.1-1.zip'
Content type 'application/zip' length 49777 bytes (48 KB)
downloaded 48 KB

trying URL 'https://mirrors.sjtug.sjtu.edu.cn/cran/bin/windows/contrib/4.2/digest_0.6.33.zip'
Content type 'application/zip' length 203986 bytes (199 KB)
downloaded 199 KB

程序包‘repr’打开成功,MD5和检查也通过
程序包‘IRdisplay’打开成功,MD5和检查也通过
程序包‘evaluate’打开成功,MD5和检查也通过
程序包‘crayon’打开成功,MD5和检查也通过
程序包‘pbdZMQ’打开成功,MD5和检查也通过
程序包‘devtools’打开成功,MD5和检查也通过
程序包‘uuid’打开成功,MD5和检查也通过
程序包‘digest’打开成功,MD5和检查也通过

下载的二进制程序包在
	C:\Users\w\AppData\Local\Temp\RtmpyqksI5\downloaded_packages里

输出结果2:

> devtools::install_github('IRkernel/IRkernel')
Downloading GitHub repo IRkernel/IRkernel@HEAD
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?

1: All                              
2: CRAN packages only               
3: None                             
4: htmltools (0.5.5 -> 0.5.6) [CRAN]
Enter one or more numbers, or an empty line to skip updates: 
── R CMD build ──────────────────────────────────────────────────────────────────────────────────────────────────
✔  checking for file 'C:\Users\Wong\AppData\Local\Temp\RtmpyqksI5\remotes609024207ead\IRkernel-IRkernel-1eddb30/DESCRIPTION' ... 
─  preparing 'IRkernel':
✔  checking DESCRIPTION meta-information ... 
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
   Removed empty directory 'IRkernel/example-notebooks'
─  building 'IRkernel_1.3.2.9000.tar.gz'
   
* installing *source* package 'IRkernel' ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (IRkernel)

上面的代码会自动分两步执行,执行完后,在输入如下代码:

#在系统下安装
IRkernel::installspec(user = FALSE)

等待执行完毕,打开jupyter就可以新建R的notebook了。

来源:

在jupyter notebook中使用R语言_jupyter r_一窗星乱银河静的博客-CSDN博客

引用:笔者为图方便使用了方法二,然后在启动jupyter的时候失败了: Jupyter server process exited with code 1 解决方法 。 引用:“jupyter kernelspec --version” exited with code 1.问题解决 。 引用:在IRkernel::installspec(user = FALSE)这一步时报错 报错代码: Error in IRkernel::installspec(user = FALSE) : jupyter-client has to be installed but “jupyter kernelspec --version” exited with code 1. 解决方式: 右键选择R,以管理员身份运行,运行 IRkernel::installspec(user = FALSE) 问题解决。 引用:我估计是jupyter kernel出现了问题,在kernel.json下修改了启动参数,指明了解释器的路径: 然后重装了jupyter内核: conda install nb_conda_kernels 。 问题:请告诉我,Jupyter server process exited with code 1 Traceback (most recent call last): File 根据提供的引用内容,"Jupyter server process exited with code 1"是指在启动Jupyter时遇到了错误,进程以1的代码退出。这个错误可能由多种原因引起。其中一种可能的解决方法是通过运行命令"jupyter kernelspec --version"来检查Jupyter内核的版本。如果这个命令返回错误代码1,可以尝试以管理员身份运行R并运行"IRkernel::installspec(user = FALSE)"命令来解决问题。另一种可能的解决方法是修改kernel.json文件中的启动参数,指定解释器的路径,并重新安装Jupyter内核。例如使用命令"conda install nb_conda_kernels"来重装Jupyter内核。<span class="em">1</span><span class="em">2</span><span class="em">3</span><span class="em">4</span>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值