配置失败,因为找不到libcurl

时间:2017-02-08 14:35:16

标签: r ubuntu curl rstudio

我正在尝试使用fromJSON从远程服务器中提取一些json数据:

> server <- 'http://111.111.000.00:3000'
> streams <- fromJSON(paste(server, '/output/streams', sep=""), flatten=TRUE)

结果:

Error: Required package curl not found. 
Please run: install.packages('curl')

所以我尝试安装它:

> install.packages("curl")
Installing package into ‘/home/lauxxx/R/x86_64-pc-linux-gnu-library/3.3’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/curl_2.3.tar.gz'
Content type 'application/x-gzip' length 400460 bytes (391 KB)
==================================================
downloaded 391 KB

* installing *source* package ‘curl’ ...
** package ‘curl’ successfully unpacked and MD5 sums checked
Using PKG_CFLAGS=
Using PKG_LIBS=-lcurl
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libcurl was not found. Try installing:
 * deb: libcurl4-openssl-dev (Debian, Ubuntu, etc)
 * rpm: libcurl-devel (Fedora, CentOS, RHEL)
 * csw: libcurl_dev (Solaris)
If libcurl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libcurl.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=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘curl’
* removing ‘/home/lauxxx/R/x86_64-pc-linux-gnu-library/3.3/curl’
Warning in install.packages :
  installation of package ‘curl’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpdoavNf/downloaded_packages’

然后我尝试安装libcurl4-openssl-dev

> install.packages("libcurl4-openssl-dev")
Installing package into ‘/home/lau/R/x86_64-pc-linux-gnu-library/3.3’
(as ‘lib’ is unspecified)
Warning in install.packages :
  package ‘libcurl4-openssl-dev’ is not available (for R version 3.3.1)

为什么呢?出了什么问题?我该如何解决?

当我在Xubuntu 16.04上时,没关系。但现在我在Kubuntu 16.10上。

有什么想法吗?

5 个答案:

答案 0 :(得分:34)

libcurl4-openssl-dev不是R包,而是Linux库。

在控制台类型中:

sudo apt-get install libcurl4-openssl-dev

注意:您需要 sudo 电源。

答案 1 :(得分:4)

尽管已经安装了libcurl4-openssl-dev apt软件包,但我在Ubuntu Server 18.04上遇到了此错误。我不得不查找where the package installs libcurl.pc来找出要使用的命令:

wget <curl-package-address>
R CMD INSTALL --configure-vars='LIB_DIR=/usr/lib/x86_64-linux-gnu/pkgconfig' <curl-file.gz>

(检查“ ANTICONF ERROR”上方的消息以下载和安装正确的文件。对于发问者,它是https://cran.rstudio.com/src/contrib/curl_2.3.tar.gz;我的是https://cloud.r-project.org/src/contrib/curl_4.3.tar.gz。)

答案 2 :(得分:1)

------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libcurl was not found. Try installing:
* deb: libcurl4-openssl-dev (Debian, Ubuntu, etc)
* rpm: libcurl-devel (Fedora, CentOS, RHEL)
* csw: libcurl_dev (Solaris)

我在 Fedora Workstation 33 中安装 R 包时遇到了这个问题。按照提示,确保为适当的架构安装 libcurl-devel,在本例中为 libcurl-devel.x86_64

sudo dnf install openssl-dev libcurl-devel.x86_64

答案 3 :(得分:0)

就我的Ubuntu 18而言,这些解决方案都无法在Rstudio中使用。

当我最终决定从命令行运行R时,成功-我无法告诉您哪个“解决方案”是关键,因为到目前为止,我已经尝试了所有这些解决方案。

请注意,如果我再次尝试运行Rstudio,则任何安装尝试仍将失败。

因此,Rstudio可能无法正确推断环境。

答案 4 :(得分:0)

刚刚在使用 GitHub 操作按 cron 计划运行 R 脚本时遇到了这个问题。

在 R 文件中将 sudo apt-get install libcurl4-openssl-dev 弹出到 system() 中有效。比单独在运行器上设置 bash 命令要容易得多。

system("sudo apt-get install libcurl4-openssl-dev")