完整报错:
Error in IRkernel::installspec() : jupyter-client has to be installed but “jupyter kernelspec --version” exited with code 127. In addition: Warning message: running command '"jupyter" kernelspec --version' had status 127
Two options:
- Find
R.exe
somewhere on your system and run this from the Anaconda prompt. Then you should be able to install IRkernel from your existing R environment. - Install R through conda. If I recall correctly, the command is
conda install -c r r-irkernel
. This is simpler because it lets conda manage everything, but it creates a separate R installation from the one Rstudio uses, which may be confusing.
从开发成员的描述来看就是说,一种自己从CRAN下载了R的安装包,去jupyter notebook配置R.
另一个是从Conda去下载。这种更简单(这个教程挺多,就不细说)
直接
> conda install -c r r-irkernel
你就可以直接使用R了,本人试了这个,不过当时没有指定版本,默认好像是R-3.x的版本,所以我install.packages下载
library(readxl) 的时候,说版本过低,不能下载。
不过由于本人电脑之前已经从CRAN安装了R-4.x版本,所以执行conda install -c r r-irkernel,其实就是重新安装了个R,导致我这个R-4.x版本已经装了的
library(readxl)用不了,所以就开始配置这个R-4.x。(当然,conda install -c r r-irkernel 应该是可以指定版本的,所以想怎么配置看个人吧)
就想用已经安装的R,所以要解决上面的Error in IRkernel::installspec()
本人装了几个conda的虚拟环境(不懂虚拟环境的就不用理),然后环境变量配置的是这个虚拟环境的路径,这是引出,Error in IRkernel::installspec()的关键原因,conda创建虚拟环境不会自动安装jupyter notebook.So, 通过conda install jupyter在虚拟环境也装上对应包.
所以,萌新或没有虚拟环境的,只需要去
环境变量配置conda的路径,指向./anaconda3/,然后进入你安装R文件夹下的bin目录,用管理员身份运行R.exe文件进入R语言,然后再次输入
> IRkernel::installspec(user = FALSE)
就ok了。
然后就
Happy coding!