unbantu 18.04 安装R语言报错E: Unable to correct problems, you have held broken packages.

在unbantu18.04上安装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

但是我再用这种方法安装时报错了

sudo apt-get install r-base
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:
 r-base : Depends: r-base-core (>= 4.0.5-1.2004.0) but it is not going to be installed
          Depends: r-recommended (= 4.0.5-1.2004.0) but it is not going to be installed
          Recommends: r-base-html but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

这是因为这种方法安装的是R语言最新的4.0.5版本,对于低版本的18.04不太适用,其中的一些依赖包不能满足要求。所以只能安装较低版本的3.6系列

方法是修改源文件

1. 修改sources.list源文件

在/etc/apt/sources.list文件末尾根据系统版本添加相应的R源

ubuntu18.04对应的是第一个(bionic-cran35)。

即在终端执行:

sudo gedit /etc/apt/sources.list

我的系统不支持gedit ,所以我采用了下面的命令手动修改添加:

sudo vim /etc/apt/sources.list file

在/etc/apt/sources.list文件中添加与系统相应的R源:

deb https://cloud.r-project.org/bin/linux/ubuntu disco-cran35/

或者

deb https://cloud.r-project.org/bin/linux/ubuntu cosmic-cran35/

或者

deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/(我的ubuntu18.04就添加的是这个)

或者

deb https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/

或者

deb https://cloud.r-project.org/bin/linux/ubuntu trusty-cran35/

将其中多余的R语言源删去,只保留自己系统版本的相应的源即可

之后执行下面命令以更新源

sudo apt update

再次执行安装命令就可以安装了

sudo apt install r-base

完成后输入

R --version

查看R语言版本是否安装成功

可以看到已成功安装。亲爱的你们赶紧去试试吧!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值