无法在 Ubuntu 18.04 上安装 R

无法在 Ubuntu 18.04 上安装 R

我刚刚从 Windows 迁移过来,成功安装了 Ubuntu 18.04,并尝试安装 R。但是,按照所述步骤操作后出现以下错误这里

$ sudo apt-get install r-base-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:
 r-base-dev : Depends: r-base-core (>= 3.5.2-1bionic) but it is not going to be installed
              Depends: build-essential but it is not installable
              Depends: gcc but it is not installable
              Depends: g++ but it is not installable
              Depends: gfortran but it is not installable
              Depends: libblas-dev but it is not installable or
                       libatlas-base-dev but it is not going to be installed
              Depends: liblapack-dev but it is not installable or
                       libatlas-base-dev but it is not going to be installed
              Depends: libncurses5-dev but it is not installable
              Depends: libreadline-dev but it is not installable
              Depends: libjpeg-dev but it is not installable
              Depends: libpcre3-dev but it is not installable


         Depends: libpng-dev but it is not installable
          Depends: zlib1g-dev but it is not installable
          Depends: libbz2-dev but it is not installable
          Depends: liblzma-dev but it is not installable
          Depends: libicu-dev but it is not installable

E: Unable to correct problems, you have held broken packages.

答案1

您尝试安装错误的软件包 -r-base-dev不包含 R 工具本身,它包含源代码,因此您可以自己编译它们。您不需要它来使用 R。

要安装 R 解释器,您应该安装包r-base,使用如下命令:

sudo apt install r-base

如果您不需要最新的 R 工具(即发布时间少于 6 个月),您可以安全地从默认的 Ubuntu 存储库安装 R,这样 APT 就可以处理所有必需的软件包。

您只需要确保universe从“软件和更新”应用程序启用存储库。

我建议您禁用之前启用的 CRAN R 存储库。您可以从“软件和更新”应用程序中执行此操作。

相关内容