问题
I have been having some trouble running the following code:
install.packages("sqldf",dep=TRUE)
library(sqldf)
install.packages("RSQLite",dep=TRUE)
library(RSQLite)
After running this, my intention is to use the sqldf function to run some queries, but I've gotten stuck on an error I'm not sure how to solve and I've had trouble finding any other answers on Stack Overflow that could be helpful.
The following is the error I receive after running the first line:
Loading required package: RSQLite
Error: package or namespace load failed for ‘RSQLite’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
namespace ‘rlang’ 0.4.0 is already loaded, but >= 0.4.2 is required
Error: package ‘RSQLite’ could not be loaded
I then tried running:
install.packages("rlang")
but received the following error:
package ‘rlang’ successfully unpacked and MD5 sums checked
Warning in install.packages :
cannot remove prior installation of package ‘rlang’
Warning in install.packages :
problem copying C:\Users\My Name\Documents\R\win-library\3.6\00LOCK\rlang\libs\x64\rlang.dll to C:\Users\My Name\Documents\R\win-library\3.6\rlang\libs\x64\rlang.dll: Permission denied
Warning in install.packages :
restored ‘rlang’
I am befuddled. Not sure how to begin addressing this issue. Any help or insight would be appreciated! Thank you!
回答1:
Updating an already-installed package requires that R is able to unload
the package. Typically this can be done easily, but often it can be problematic, specifically with packages that have compiled libraries (.so
, .lib
, or .dll
, depending on the SO). I don't know the steps required to be able to disentangle shared objects like those, but it often just doesn't work. This can leave the updating process in a bad state: (1) not updated but still usable for this and current sessions; or (2) not updated and the on-disk store in a partial state that cannot be used (perhaps other states).
Even though it is possible to update packages with shared objects, the only guaranteed way (especially if you are experiencing problems) is to restart R into a state that does not have that package loaded. If you are auto-loading packages (due to .Rprofile
or .Rdata
), then you will need to make sure to start without those measures (perhaps a "new project" and/or move the .Rprofile
temporarily out of the way).
So ... restart R and re-attempt the install/update of all failed packages.
来源:https://stackoverflow.com/questions/60174542/r-error-when-trying-to-load-the-sqldf-package