Error: package or namespace load failed for ‘mapview’

Hi, I am having an error loading mapview. I can install the package, but when I go to load the package, I get the below error:

library(mapview)
Error: package or namespace load failed for ‘mapview’:
Function found when exporting methods from the namespace ‘raster’ which is not S4 generic: ‘all.equal’
In addition: Warning message:
no function found corresponding to methods exports from ‘raster’ for: ‘direction’, ‘gridDistance’

I also can't do the tutorial where you are supposed to view the breweries. When I do mapview(breweries), I get the following error:

mapview(breweries)
Error in mapview(breweries) : could not find function "mapview"

I'm using R Version 4.1.2 (2021-11-01).

Any ideas on what coupld be going wrong?

Thanks!

Try reinstalling/updating the raster package

install.packages("raster")

Ok - tried that, still getting the same error. Any other ideas?
Thank you!

Have you got any error message while installing raster? Please post the complete output message you get when you try to install it, that could give us another clue about what the problem is.

1 Like

Good morning,
I have the same issue with using R 4.1.2.
I had no error message with the install.packages('raster') but the library(raster) step return the following message:

library(raster)
Error: package or namespace load failed for ‘raster’:
Function found when exporting methods from the namespace ‘raster’ which is not S4 generic: ‘all.equal’
In addition: Warning message:
no function found corresponding to methods exports from ‘raster’ for: ‘direction’, ‘gridDistance’.

Thank you.

Hi,

one of my colleagues had that same problem, and she solved it
first reinstalling rtools
then raster
then mapview...

Hope this helps...

Thank you for this tips!
It works now.
I followed this tutoriel for Rtools installation Using Rtools4 on Windows

Good bye.

Hi everyone,

Thanks for your help. I've tried uninstalling and then installing rtools, raster, then mapview, and I am still having the same issues. When I try to load raster, I get the below error:

library(raster)
Loading required package: sp
Error: package or namespace load failed for ‘raster’:
Function found when exporting methods from the namespace ‘raster’ which is not S4 generic: ‘all.equal’
In addition: Warning message:
no function found corresponding to methods exports from ‘raster’ for: ‘direction’, ‘gridDistance’

Hi pioneer

I have the exact same problem and solved it as follows:

install.packages('raster', repos='https://rspatial.r-universe.dev')

I was trying to load the unmarked package and got the same error message. I didn't try to reinstall Rtools but if I ran the single line of code and then library(raster) it solved the problem. Then, if I ran library(unmarked) the package loaded properly.

Hope it helps!

Additionally, you may need to also run the following:

install.packages('terra', repos='https://rspatial.r-universe.dev')

Credit to: Incompatibility with AMD Ryzen CPU? · Issue #620 · r-tmap/tmap · GitHub

Hi James,

I am having the same problem as pioneer and yourself. I tried using your solution and received this message when trying install.packages('raster', repos='h ttps://rspatial.r-universe.dev'):

WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

h ttps://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/thoma/Documents/R/win-library/4.1’
(as ‘lib’ is unspecified)
Warning in install.packages :
unable to access index for repository h ttps://rspatial.r-universe.dev /src/contrib:
cannot open URL 'h ttps://rspatial.r-universe.dev /src/contrib/PACKAGES'
Warning in install.packages :
package ‘raster’ is not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
h ttps://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
Warning in install.packages :
unable to access index for repository h ttps://rspatial.r-universe.dev /bin/windows/contrib/4.1:
cannot open URL 'h ttps://rspatial.r-universe.dev /bin/windows/contrib/4.1/PACKAGES'

Ignore the spaces in each 'https'. I had to break the links in this post because I am a new user on this site and cannot include multiple links in a post.

All the best,

Hi Thomas

In your case it seems that you need to uninstall if you alread have it and then reinstall the latest version of Rtools before running this command. Also, be sure that you're using the latest version of R. I am currently running R4.1.2 and it may not cause a problem but it is worth always having the latest version of R.

Hi James,

I do not believe I have RTools installed, so that must be my problem. Thanks, I'll give that a go!

All the best,

Hi James,

Installing RTools worked, thanks for the help!

All the best,

Hi Thomas,

Could you share with us how is the procedure of installing RTools and installing the raster package from it?
I have tried to install the raster package many times but i always get the error message:

"Function found when exporting methods from the namespace ‘raster’ which is not S4 generic: ‘all.equal’"

Thank you in advance

Hi maarciom,

I installed Rtools from this page: Using Rtools4 on Windows

After the installation was completed, I tried 'install.packages("raster", dependencies = TRUE)' again and it seems to work now.

Hope that helps!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.