【问题标题】:R - cannot access urls for package installationR - 无法访问包安装的 url
【发布时间】:2016-03-11 02:47:34
【问题描述】:

我最近在个人计算机(Windows 8)上安装了 R Studio(版本 0.99.892),并尝试安装以下软件包: ggplot2; dplyr; 降价; 整洁。

R 和 R Studio 都不能安装任何这些包。每次我尝试安装软件包时,都会收到我在这篇文章底部包含的一组警告。

我使用了 install.packages 命令以及内置的包安装工具。我尝试了几种不同的镜子。

我尝试过公立大学互联网资源、我自己的私人互联网资源和电话线。我尝试通过 VPN 连接。我已将 R Studio 添加到我的 Windows 防火墙例外列表中,并且还完全禁用了 Windows 防火墙。我没有运行其他防火墙。

我已在全局选项的“包”选项卡中切换了各种连接选项。

我可以在浏览器中访问这些 URL。

以下是来自 R Studio 的警告:

> install.packages("devtools")
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  unable to access index for repository https://cran.fhcrc.org/src/contrib:
  cannot open URL 'https://cran.fhcrc.org/src/contrib/PACKAGES'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be     resolved'
Warning in install.packages :
  unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib:
  cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES'
Installing package into ‘C:/Users/Nikhailovich/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  unable to access index for repository https://cran.fhcrc.org/src/contrib:
  cannot open URL 'https://cran.fhcrc.org/src/contrib/PACKAGES'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib:
  cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES'
Warning in install.packages :
  package ‘devtools’ is not available (for R version 3.2.3)
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  unable to access index for repository https://cran.fhcrc.org/bin/windows/contrib/3.2:
  cannot open URL 'https://cran.fhcrc.org/bin/windows/contrib/3.2/PACKAGES'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.2:
  cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.2/PACKAGES'

以下是来自 R (3.2.3) 的警告:

> install.packages("ggplot2")
Installing package into ‘C:/Users/Nikhailovich/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Error in download.file(url, destfile = f, quiet = TRUE) : 
  cannot open URL 'https://cran.r-project.org/CRAN_mirrors.csv'
In addition: Warning message:
In download.file(url, destfile = f, quiet = TRUE) :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning: unable to access index for repository https://dirichlet.mat.puc.cl/src/contrib:
  cannot open URL 'https://dirichlet.mat.puc.cl/src/contrib/PACKAGES'
Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib:
  cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES'
Warning: unable to access index for repository https://dirichlet.mat.puc.cl/bin/windows/contrib/3.2:
  cannot open URL 'https://dirichlet.mat.puc.cl/bin/windows/contrib/3.2/PACKAGES'
Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.2:
  cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.2/PACKAGES'
Warning message:
package ‘ggplot2’ is not available (for R version 3.2.3) 

在 R 和 R Studio 中有几篇关于包安装的 stackexchange 帖子,但我找不到任何可以回答我的特殊情况的帖子。提前感谢任何知道发生了什么的人

【问题讨论】:

    标签: r package


    【解决方案1】:

    运行这个命令:

    options(repos="https://CRAN.R-project.org")
    

    然后尝试 install.packages;它应该可以工作。在我的系统上测试。

    【讨论】:

    • 救命稻草。谢谢!
    【解决方案2】:

    我以前也遇到过这种情况。尝试明确指定位置:

    install.packages("devtools", repos="https://cran.rstudio.com/")
    

    【讨论】:

      【解决方案3】:

      您确实可以在使用install.packages() 函数和repos= 参数时指定位置,但您也可以选择您喜欢的存储库,每次下载包时都会使用该存储库。

          options(repos="my_favorite_CRAN_mirror")
      

      您可以在CRAN website 上查看所有可用镜像的列表。只需复制/粘贴离您最近的 CRAN 存储库的地址即可。

      这一步之后你应该可以重试install.packages('ggplot2')

      【讨论】:

        【解决方案4】:

        您应该尝试以下代码:

        install.packages("ggbiplot",dependencies = TRUE, repos = 'http://cran.rstudio.com/')
        

        它将帮助您安装错误的软件包:

        此版本不提供软件包

        【讨论】:

          【解决方案5】:

          在 R 终端中运行以下命令- 选项(repos="https://CRAN.R-project.org") 然后- 使用-install.packages('库')

          【讨论】:

            【解决方案6】:

            我想补充一点,我遇到了这个问题,但修复不是在 R 中,而是在我们的系统中。我们的 IT 人员说:由于某种未知原因,DNS 解析器服务无法解析主机名。我已经重新启动了 resolvd 服务。服务器现在可以解析主机名了。

            他的错误是:名称解析暂时失败

            【讨论】:

              【解决方案7】:

              我在尝试安装 dplyrtidyr 软件包时遇到了类似的错误。 我通过检查我的R.version 并下载新版本的 base R. (3.3.3) 解决了这个问题

              【讨论】:

                【解决方案8】:

                试试这个...

                工具-->全局选项-->包

                将“主要 CRAN 存储库”更改为 htpps 位置

                这个方法解决了我的问题

                【讨论】:

                  猜你喜欢
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  • 2021-05-08
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  相关资源
                  最近更新 更多