我想安装 R 和 Rstudio 来开始学习,但是发现有很多问题,下面我会尽可能详细地解释。
所以我去了 CRAN 项目网站https://cran.r-project.org/并按照他们的说明在我的笔记本电脑上安装 R。
# update indices
apt update -qq
# install two helper packages we need
apt install --no-install-recommends software-properties-common dirmngr
# import the signing key (by Michael Rutter) for these repo
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
# add the R 4.0 repo from CRAN -- adjust 'focal' to 'groovy' or 'bionic' as needed
add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
apt install --no-install-recommends r-base
之后,我进入 RStudio 网页并下载rstudio-server-1.4.1717-amd64.deb
。首先,我尝试使用 GUI 安装它,但出现以下消息:
GPG 错误:https://cloud.r-project.org/bin/linux/ubuntufocal-cran40/InRelease:由于公钥不可用,无法验证以下签名:NO_PUBKEY 51716619E084DAB9
存储库“https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/InRelease”尚未签名。
从这样的存储库进行更新并不安全,因此默认情况下是禁用的。
有关存储库创建和用户配置的详细信息,请参阅 apt-secure(8) 手册页。
然后我尝试安装它,sudo apt install ./rstudio-server-1.4.1717-amd64.deb
并发生了以下情况:
Note, selecting 'rstudio' instead of './rstudio-1.4.1717-amd64.deb'
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
rstudio : Depends: libclang-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
最后,由于我发现许多使用 gdebi 安装的教程,所以我又尝试了一次:
gdebi rstudio-1.4.1717-amd64.deb
得出的结果是:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading state information... Done
This package is uninstallable
Cannot install 'libclang-dev'
显然 libclang-dev 出现了问题,我尝试安装它:
sudo apt install libclang-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libclang-dev : Depends: libclang-10-dev (>= 10~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
因此,我尝试安装 libclang-10-dev,但它又带来了另一个与此处所示的依赖关系问题类似的问题。我认为手动安装不会很快结束这一连串问题。
我可以给你的最后几条信息是:
当我运行时rstudio
它说command not found
。
现在当我这样做时,apt update
我得到了与上面相同的消息,以“GPG”开头
我可以提供的最后一条信息是,当我R
在命令行中运行时,我可以从那里使用 R 语言。
如果您碰巧知道我可以做些什么来解决这个问题,我将不胜感激。
答案1
为了解决安装问题,我发现了以下内容:
https://stackoverflow.com/questions/67383617/unable-to-install-rstudio-cannot-install-libclang-dev
首先需要安装 aptitude
sudo apt install aptitude
然后你可以运行
sudo aptitude install clang
说不对于第一个问题,是的到第二个。
然后您可以使用 gdebi 安装 RStudio。
答案2
https://www.geeksforgeeks.org/how-to-install-r-studio-on-windows-and-linux/#:~:text=Installing%20R%20Studio%20on%20Ubuntu&text=Step%201%3A%20Open%20terminal%20(Ctrl,2%3A%20Update%20the%20package's%20cache.&text=Step%203%3A%20Install%20R%20environment.&text=Step%204%3A%20使用以下命令检查%20R%20安装。
请检查一下这个是否可以