R/RStudioのインストールパッケージ「サーバと接続できない」を解決

5998 ワード

ここ数日、RStudioでプログラムを書いていたところ、突然、rパッケージをネットワークから直接インストールできない、ローカルから直接インストールできないという問題が発生しました.いろいろ試して問題解決の方法を見つけましたが、ここに記録します.プログラムエラーは以下の通りです.

> install.packages('REmap')
Warning in install.packages :
  unable to access index for repository https://cran.rstudio.com/src/contrib:
  cannot open URL 'https://cran.rstudio.com/src/contrib/PACKAGES'
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 :
  unable to access index for repository https://cran.rstudio.com/src/contrib:
  cannot open URL 'https://cran.rstudio.com/src/contrib/PACKAGES'
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 ‘REmap’ is not available (for R version 3.4.1)
Warning in install.packages :
  unable to access index for repository https://cran.rstudio.com/bin/windows/contrib/3.4:
  cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/PACKAGES'
Warning in install.packages :
  unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.4:
  cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.4/PACKAGES'
Warning: unable to access index for repository https://cran.rstudio.com/src/contrib:
  cannot open URL 'https://cran.rstudio.com/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'

ネットワーク上の主流の解決策はtools-global options-packagesでダウンロードしたミラーを切り替えることであり、多くの人が彼らの問題がこの方法で解決されたことを反映しているが、私は多くのミラーを交換しても役に立たない.もう1つの方法は、ファイルを修正し、インストールフォルダにRprofileを見つけることです.siteファイル、私のパスはD:Program FilesRR-3.4.1etcで、手帳で開けて、中に文を追加します:
# set a CRAN mirror local({r r[“CRAN”] options(repos=r)}
これもミラーを設定する方法で、方法と同じです.私にも役に立たない.
その後Rの中でinstallを知りました.packages()はieブラウザからミラーに接続されているため、サーバに接続できないのはieの一環で問題が発生した可能性が高い.コンピュータのieブラウザを開けて正常にインターネットを利用することができるかどうかを見て、もしエージェントの問題を表示するならば、ツール-インターネットのオプション-接続の中でローカルエリアネットワークの設定の中のエージェントのサーバーのこの項目を削除してチェックを外します.これで正常にインターネットに接続できます.RStudioを再確認しても正常にrパッケージをインストールできます.
その後、別の問題が発生しました.
> install.packages('sp')
trying URL 'https://cran.wu.ac.at/bin/windows/contrib/3.4/sp_1.2-5.zip'
Content type 'application/zip' length 1538503 bytes (1.5 MB)
downloaded 1.5 MB

package ‘sp’ successfully unpacked and MD5 sums checked
Warning in install.packages :
  unable to move temporary installation ‘D:\Program Files\R\R-3.4.1\library\file4041367c44\sp’ to ‘D:\Program Files\R\R-3.4.1\library\sp’

The downloaded binary packages are in
    C:\Users\asus\AppData\Local\Temp\RtmpWOz6Xu\downloaded_packages

ウイルス対策ソフトウェアがこのような操作を禁止している可能性があるため、インストールパッケージを一時ディレクトリから移行できません.ウイルス対策ソフトのホワイトリストにRがインストールされているフォルダを入れ、RStudioを再起動すると問題が解決します.あるいは面倒なことに、この圧縮ファイルを仮ディレクトリでRインストールディレクトリのlibraryフォルダに解凍します.