简体   繁体   English

R即使在安装包后也找不到包

[英]R not finding package even after package installation

I have always worked with the zoo package, that I have installed a long time ago.我一直使用我很久以前安装的zoo包。 Today, I created a new R script, and ran library(zoo) and got the following error:今天,我创建了一个新的 R 脚本,然后运行library(zoo)并得到以下错误:

 > library(zoo)
 Error in library(zoo) : there is no package called ‘zoo’

Odd.. Still, I tried reinstalling the package using install.packages("zoo") , and get the following:奇怪.. 不过,我尝试使用install.packages("zoo")重新安装包,并得到以下内容:

 > install.packages("zoo")
 Installing package(s) into ‘C:/Users/U122337.BOSTONADVISORS/Documents/R/win-library/2.15’
 (as ‘lib’ is unspecified)
 --- Please select a CRAN mirror for use in this session ---
 trying URL 'http://cran.cnr.Berkeley.edu/bin/windows/contrib/2.15/zoo_1.7-10.zip'
 Content type 'application/zip' length 874474 bytes (853 Kb)
 opened URL
 downloaded 853 Kb

 package ‘zoo’ successfully unpacked and MD5 sums checked
 Warning: cannot remove prior installation of package ‘zoo’

The downloaded binary packages are in
    C:\Users\U122337.BOSTONADVISORS\AppData\Local\Temp\Rtmp404t8Y\downloaded_packages

When I try uploading the package, I get the error again that the zoo package doesn't exist.当我尝试上传包时,我再次收到zoo包不存在的错误。

I have no idea what's happening.我不知道发生了什么。 I exited the GUI and restarted it, same problem.我退出 GUI 并重新启动它,同样的问题。 I have always worked with this package, and I have no idea why this is happening now.我一直在使用这个包,我不知道为什么现在会发生这种情况。

Do .libPaths() , close every R runing, check in the first directory, remove the zoo package restart R and install zoo again.执行.libPaths() ,关闭每个 R 运行,检查第一个目录,删除zoo包重新启动 R 并再次install zoo Of course you need to have sufficient rights.当然你需要有足够的权限。

When you run当你跑

install.packages("whatever")

you got message that your binaries are downloaded into temporary location (eg The downloaded binary packages are in C:\\Users\\User_name\\AppData\\Local\\Temp\\RtmpC6Y8Yv\\downloaded_packages ).您收到消息,您的二进制文件已下载到临时位置(例如,下载的二进制包位于 C:\\Users\\User_name\\AppData\\Local\\Temp\\RtmpC6Y8Yv\\downloaded_pa​​ckages 中)。 Go there.去那里。 Take binaries (zip file).获取二进制文件(zip 文件)。 Copy paste into location which you get from running the code:将粘贴复制到您通过运行代码获得的位置:

.libPaths()

If libPaths shows 2 locations, then paste into second one.如果 libPaths 显示 2 个位置,则粘贴到第二个位置。 Load library:加载库:

library(whatever)

Fixed.固定。

I had this problem and the issue was that I had the package loaded in another R instance.我遇到了这个问题,问题是我在另一个 R 实例中加载了包。 Simply closing all R instances and installing on a fresh instance allowed for the package to be installed.只需关闭所有 R 实例并在新实例上安装即可安装包。

Generally, you can also install if every remaining instance has never loaded the package as well (even if it installed an old version).通常,如果剩余的每个实例都从未加载过包(即使它安装了旧版本),您也可以安装。

So the package will be downloaded in a temp folder C:\\Users\\U122337.BOSTONADVISORS\\AppData\\Local\\Temp\\Rtmp404t8Y\\downloaded_packages from where it will be installed into your library folder, eg C:\\R\\library\\zoo因此,该软件包将下载到临时文件夹 C:\\Users\\U122337.BOSTONADVISORS\\AppData\\Local\\Temp\\Rtmp404t8Y\\downloaded_pa​​ckages 中,然后将安装到您的库文件夹中,例如 C:\\R\\library\\zoo

What you have to do once install command is done: Open Packages menu -> Load package...安装命令完成后你必须做的事情:打开包菜单 -> 加载包...

You will see your package on the list.您将在列表中看到您的包裹。 You can automate this: How to load packages in R automatically?您可以自动执行此操作: 如何在 R 中自动加载包?

go to this folder C:\\Users\\hp\\Documents\\R\\win-library\\4.0 in your PC.转到 PC 中的此文件夹 C:\\Users\\hp\\Documents\\R\\win-library\\4.0。 And delete '00LOCK' named folder.并删除“00LOCK”命名的文件夹。 then It will work properly, THis folder is being locked all incoming file.IF your delete this , then it will work.那么它会正常工作,这个文件夹被锁定了所有传入的文件。如果你删除它,那么它就会工作。

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

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