简体   繁体   English

在 RStudio 中安装包时出错:从连接读取错误

[英]Error installing packages in RStudio: error reading from connection

I have recently updated both R (version 3.4.1) and RStudio (version 1.0.143) and I am now unable to install packages from Rstudio.我最近更新了 R(版本 3.4.1)和 RStudio(版本 1.0.143),现在我无法从 Rstudio 安装软件包。

If I install a package in R directly using install.packages() it works fine.如果我直接使用install.packages()在 R 中安装一个包,它工作正常。

If I try and install a package in Rstudio using either install.packages() or using the package install menu I get the error below.如果我尝试使用install.packages()或使用包安装菜单在 Rstudio 中安装包,我会收到以下错误。 I have tried a few different packages, and have uninstalled and reinstalled both R and RStudio.我尝试了几个不同的软件包,并卸载并重新安装了 R 和 RStudio。

To get the error:要获取错误:

Run:运行:

install.packages("lme4")

Output:输出:

Installing package into ‘E:/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
also installing the dependencies ‘minqa’, ‘nloptr’, ‘RcppEigen’

Warning in install.packages :
lzma decoding result 10
Error in install.packages : error reading from connection

I am working off my personal computer, below is some of my system info:我在我的个人电脑上工作,下面是我的一些系统信息:

Output from options("repos") options("repos")输出options("repos")

$repos
                        CRAN                            CRANextra 
 "https://cran.stat.auckland.ac.nz/" "http://www.stats.ox.ac.uk/pub/RWin" 
 attr(,"RStudio")
[1] TRUE

Output from sessionInfo() sessionInfo()输出

R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_New Zealand.1252  LC_CTYPE=English_New Zealand.1252    
LC_MONETARY=English_New Zealand.1252
[4] LC_NUMERIC=C                         LC_TIME=English_New Zealand.1252    


attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.4.1 tools_3.4.1   

This certainly is an issue with your connection:the proxies you are using and repositories configured in your RStudio.这当然是您的连接问题:您使用的代理和 RStudio 中配置的存储库。 I was getting the same error when I was connected to US VPN from India.I disconnected VPN and restarted RStudio and it worked like a charm!当我从印度连接到美国 VPN 时,我遇到了同样的错误。我断开了 VPN 并重新启动了 RStudio,它就像一个魅力!

I had the same issue when I tried to install caret .当我尝试安装caret时遇到了同样的问题。

The best solution is to restart R studio.最好的解决办法是重启R studio。

Now the install.packages() works fine.现在install.packages()工作正常。

只需重新启动它对我有用的 R 工作室。

I had the same issue after I misspelled a package name when trying to install it.我在尝试安装时拼错了包名后遇到了同样的问题。 I restarted R Studio and then it worked.我重新启动了 R Studio,然后它工作了。

请通过以下选项在 R Studio 中选择合适的 CRAN 镜像:Tools>>>Packages>>>CRAN Mirror(根据您的位置选择合适的 CRAN)。

A simple solution would be to download manually the zip folder of the package and install it with the command : install.packages('package.zip', lib='destination_directory',repos = NULL)一个简单的解决方案是手动下载包的 zip 文件夹并使用以下命令安装它: install.packages('package.zip', lib='destination_directory',repos = NULL)

  • Package zip : the path to the zip file of the package包 zip : 包的 zip 文件的路径
  • Destination_directory: where the packages are installed by default like C:/Users/unknown/Documents/R/win-library/3.3 Destination_directory:默认安装包的位置,如C:/Users/unknown/Documents/R/win-library/3.3

Hope it helps希望它有帮助

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

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