R 語言 required package could not be found


問題發現

安裝了R 和 Rstudio 發現任何package都安裝不上,會反饋如如下錯誤:

required package could not be found

比如我需要新建notebook,但是卻顯示如下錯誤:

Warning: unable to access index for repository https://cran.rstudio.com/src/contrib:
  無法打開URL'https://cran.rstudio.com/src/contrib/PACKAGES'
Warning: unable to access index for repository https://cran.rstudio.com/src/contrib:
  無法打開URL'https://cran.rstudio.com/src/contrib/PACKAGES'

嘗試

我尋思難道是這網站被牆了? 於是我使用以下命令切換成清華鏡像:

options(repos=structure(c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/")))

但是只不過錯誤換成了:

Warning: unable to access index for repository https://mirrors.tuna.tsinghua.edu.cn/CRAN/:
  無法打開URL'https://mirrors.tuna.tsinghua.edu.cn/CRAN/'

但是清華的鏡像我是能用chrome打開的呀,清華可是我們自己銀。於是我就開始bing,bing到一個哥跟我一樣的錯誤在stackoverflow上,但是stackoverflow被牆。於是就找到這一篇:https://blog.csdn.net/truffle528/article/details/77200710

只不過其中的報錯信息是中文,而我的是英文。在將其默認查找地址設為清華鏡像之后,還是報錯,於是通過第二個方法解決。

解決

  1. 打卡IE瀏覽器,是否可以訪問https://mirrors.tuna.tsinghua.edu.cn/CRAN/
  2. 不能。 則進行設置,去掉代理(如圖)。
  3. 解決


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM