简体   繁体   English

如何在 Ubuntu 16.04 和 17.04 上安装 Tidyverse

[英]How to install Tidyverse on Ubuntu 16.04 and 17.04

I'm running Ubuntu 16.04 [now 17.04: see note in bold below] and R 3.4.1.我正在运行 Ubuntu 16.04 [现在是 17.04:请参阅下面的粗体注释] 和 R 3.4.1。 I installed the latter this morning, so I presume it's the latest version.我今天早上安装了后者,所以我认为它是最新版本。 I want to install Tidyverse, which I've spent many happy hours with under Windows.我想安装 Tidyverse,我在 Windows 下度过了许多快乐时光。 But when I do install.packages("tidyverse") , I get errors about unrecognized command line options to gcc.但是当我执行install.packages("tidyverse")时,我收到有关 gcc 无法识别的命令行选项的错误。 These start when the install hits the colorspace and munsell packages.这些在安装命中 colorspace 和 munsell 包时开始。 I'll show an example at the end of this post, just for munsell.我将在本文末尾展示一个示例,仅用于 munsell。

I've not found anyone else who had exactly that problem on Ubuntu 16.04.我还没有找到其他人在 Ubuntu 16.04 上遇到过这个问题。 But posts from people with similar problems suggest that my gcc might be a version that's too old to recognise the options -fstack-protector-strong and -Wdate-time.但是有类似问题的人的帖子表明我的 gcc 可能是一个太旧的版本,无法识别选项 -fstack-protector-strong 和 -Wdate-time。

Possible work-arounds that I've thought of:我想到的可能的解决方法:

1) Update Ubuntu to 16.10 or 17.04 in the hope that one of these has a suitable gcc. 1) 将 Ubuntu 更新到 16.10 或 17.04,希望其中一个具有合适的 gcc。 However, I'm hitting my lack of Ubuntu expertise here: in particular, it appears that I have to upgrade twice, once to 16.10 and then again to 17.04.但是,我在这里遇到了我缺乏 Ubuntu 专业知识的问题:特别是,我似乎必须升级两次,一次升级到 16.10,然后再次升级到 17.04。 I can't even make the system upgrade to 16.10: the steps recommended at https://wiki.ubuntu.com/YakketyYak/ReleaseNotes , "Upgrading from Ubuntu 16.04 LTS", don't find upgrades when I try them.我什至无法将系统升级到 16.10: https ://wiki.ubuntu.com/YakketyYak/ReleaseNotes 推荐的步骤,“从 Ubuntu 16.04 LTS 升级”,当我尝试升级时找不到升级。 Also, I don't know for sure whether either of those Ubuntus would have the right gcc.另外,我不确定这些 Ubuntu 中是否有合适的 gcc。

Added the following day: Although my attempts to upgrade Ubuntu by following https://wiki.ubuntu.com/YakketyYak/ReleaseNotes did nothing yesterday, they did work today.第二天添加:虽然我尝试按照https://wiki.ubuntu.com/YakketyYak/ReleaseNotes升级 Ubuntu 昨天没有做任何事情,但他们今天确实有效。 Maybe a caching problem?也许是缓存问题? So I now have Ubuntu 17.04.所以我现在有了 Ubuntu 17.04。 However, I still get the same errors when trying to install Tidyverse.但是,我在尝试安装 Tidyverse 时仍然遇到同样的错误。

2) Find an older version of Tidyverse that doesn't need those compiler options. 2) 找到不需要那些编译器选项的旧版 Tidyverse。

3) Upgrade my Ubuntu's gcc. 3) 升级我的 Ubuntu 的 gcc。 But I don't know whether that would nuke other software on my machine that expects an older gcc.但我不知道这是否会破坏我机器上需要较旧 gcc 的其他软件。

4) Install a new gcc just for Tidyverse, and somehow play with paths to fool the installer into calling it, perhaps by following the advice in https://askubuntu.com/questions/466651/how-do-i-use-the-latest-gcc-on-ubuntu . 4) 为 Tidyverse 安装一个新的 gcc,并以某种方式使用路径来欺骗安装程序调用它,也许是按照https://askubuntu.com/questions/466651/how-do-i-use-the中的建议-latest-gcc-on-ubuntu But that sounds risky.但这听起来很冒险。

5) Scrap Ubuntu and do all my work on Windows. 5) 废弃 Ubuntu 并在 Windows 上完成我所有的工作。 I know people deride "Micro$oft", but at least with Windows, I don't waste a morning with Linux arcana and can do my job, which is R. This is feeling far too much like the priests with their incantations in https://people.dsv.su.se/~jpalme/s1/hoare.pdf , "Software Design: a Parable".我知道人们嘲笑“Micro$oft”,但至少在 Windows 上,我不会在 Linux arcana 上浪费一个上午,并且可以完成我的工作,那就是 R。这感觉太像牧师在https中的咒语了://people.dsv.su.se/~jpalme/s1/hoare.pdf ,“软件设计:一个寓言”。 Just saying...只是说...

Any suggestions from someone who has actually done this with these versions of R and Ubuntu?使用这些版本的 R 和 Ubuntu 实际完成此操作的人有什么建议吗?

Here's an install that failed:这是一个失败的安装:

`> install.packages("munsell")
Installing package into ‘/home/popx/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
also installing the dependency ‘colorspace’

trying URL 'https://cran.rstudio.com/src/contrib/colorspace_1.3-2.tar.gz'
Content type 'application/x-gzip' length 293433 bytes (286 KB)
==================================================
downloaded 286 KB

trying URL 'https://cran.rstudio.com/src/contrib/munsell_0.4.3.tar.gz'
Content type 'application/x-gzip' length 97244 bytes (94 KB)
==================================================
downloaded 94 KB

* installing *source* package ‘colorspace’ ...
** package ‘colorspace’ successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c colorspace.c -o colorspace.o
gcc: error: unrecognized command line option '-fstack-protector-strong'
gcc: error: unrecognized command line option '-Wdate-time'
/usr/lib/R/etc/Makeconf:159: recipe for target 'colorspace.o' failed
make: *** [colorspace.o] Error 1
ERROR: compilation failed for package ‘colorspace’
* removing ‘/home/popx/R/x86_64-pc-linux-gnu-library/3.4/colorspace’
Warning in install.packages :
  installation of package ‘colorspace’ had non-zero exit status
ERROR: dependency ‘colorspace’ is not available for package ‘munsell’
* removing ‘/home/popx/R/x86_64-pc-linux-gnu-library/3.4/munsell’
Warning in install.packages :
  installation of package ‘munsell’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpQ8FW70/downloaded_packages’
Warning message:
R graphics engine version 12 is not supported by this version of RStudio. The Plots tab will be disabled until a newer version of RStudio is installed.

In some cases I find that I need to install the Ubuntu packages.在某些情况下,我发现我需要安装 Ubuntu 软件包。 To install the Tidyverse I added要安装我添加的 Tidyverse

sudo apt-get install r-cran-curl r-cran-openssl r-cran-xml2

After installing these packages, I could install the Tidyverse.安装这些软件包后,我可以安装 Tidyverse。

I run into the same problem, using elementary loki, based on ubuntu 16.04.我遇到了同样的问题,使用基于 ubuntu 16.04 的基本 loki。 Reading the output, I realized there was a very informative error message, that looked like this阅读输出,我意识到有一个非常有用的错误消息,看起来像这样

    ------------------------- ANTICONF ERROR ---------------------------
Configuration failed because openssl was not found. Try installing:
 * deb: libssl-dev (Debian, Ubuntu, etc)
 * rpm: openssl-devel (Fedora, CentOS, RHEL)
 * csw: libssl_dev (Solaris)
 * brew: openssl@1.1 (Mac OSX)
If openssl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a openssl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'

So I followed each prompt, installing the required deb, which came up to所以我按照每个提示安装了所需的 deb,结果

sudo apt-get install libssl-dev libxml2-dev libcurl4-openssl-dev 

and it worked, after I had already tried installing the cran packages listed above, without adding the new repositories.在我已经尝试安装上面列出的 cran 包之后,它起作用了,而没有添加新的存储库。

I believe had a similar problem trying to install the tidyverse package.我相信在尝试安装 tidyverse 软件包时遇到了类似的问题。 Being reasonably new to Linux and a complete rookie to R, I followed the Ubuntu installation intructions on the CRAN Project's homepage .作为 Linux 的新手和 R 的新手,我按照CRAN 项目主页上的 Ubuntu 安装说明进行操作。 When I installed R, I deliberately skipped installation of the r-base-dev package, as it said it was intended for "package maintainers".当我安装 R 时,我故意跳过了 r-base-dev 包的安装,因为它说它是为“包维护者”准备的。 I didn't really read the latter part or understand the necessity for compiling packages myself.我并没有真正阅读后面的部分,也没有理解自己编译包的必要性。

Anyway, installing r-base-dev package, and allowed me to install the Tidyverse package without problems.无论如何,安装r-base-dev包,并允许我安装 Tidyverse 包没有问题。 The complete steps to get it to work should be something like below.让它工作的完整步骤应该如下所示。 In terminal do the following steps (Step 1-3 may or may not be necessary, but I've added them just in case):在终端中执行以下步骤(步骤 1-3 可能需要也可能不需要,但我添加了它们以防万一):

  1. Add deb https://<my.favorite.cran.mirror>/bin/linux/ubuntu artful/ in your /etc/apt/sources.list file, replacing by the actual URL of your favorite CRAN mirror./etc/apt/sources.list文件中添加deb https://<my.favorite.cran.mirror>/bin/linux/ubuntu artful/ ,替换为您最喜欢的 CRAN 镜像的实际 URL。 See https://cran.r-project.org/mirrors.html for the list of CRAN mirrors.有关 CRAN 镜像列表,请参阅https://cran.r-project.org/mirrors.html
  2. Add the repository key to your system:将存储库密钥添加到您的系统:

     sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9

    An alternate method can be used by retrieving the key with可以通过检索密钥来使用另一种方法

    gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9

    and then feed it to apt-key with然后将其提供给 apt-key

     gpg -a --export E084DAB9 | sudo apt-key add -
  3. To install the complete R system, use要安装完整的 R 系统,请使用

    sudo apt-get update sudo apt-get install r-base
  4. Then comes the step I missed, that proved crucial to be able to compile the packages within the Tidyverse package , namely installing the r-base-dev package:然后是我错过的步骤,这被证明对于编译 Tidyverse 包中的包至关重要,即安装r-base-dev包:

     sudo apt-get install r-base-dev
  5. Then in RStudio execute the package installation command:然后在 RStudio 中执行包安装命令:

     install.packages(tidyverse)

Hopefully this will work for you as well.希望这也对你有用。 Read the installation guide on the CRAN Projects homepages for further about the installation procedure.阅读 CRAN 项目主页上的安装指南,了解有关安装过程的更多信息。

Add CRAN repo添加 CRAN 仓库

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

sudo add-apt-repository ppa:c2d4u.team/c2d4u4.0+
sudo apt-get r-cran-tidyverse

Then you're installing tidyverse from binary rather than compiling 100 times quicker.然后你从二进制安装 tidyverse,而不是编译速度快 100 倍。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM