Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Error in library(ggspatial) : there is no package called ‘ggspatial’ #104

Open
newusersayshi opened this issue Sep 29, 2022 · 4 comments

Comments

@newusersayshi
Copy link

Can't load this package

my code:

install.packages(c("ggplot2", "devtools", "dplyr", "stringr"))
install.packages(c("maps", "mapdata", "ggmap", "sf", "ggspatial")) 

library(ggplot2)
library(ggmap)
library(maps)
library(mapdata)
library(ggspatial) 

throws error:
RInterpreterError: Failed to parse and evaluate line 'library(ggsn)\n'.
R error message: 'Error in library(ggsn) : there is no package called ‘ggspatial’'

This happens on google colab, and R studio (version 4.0.2 (2020-06-22)).

Full eror from colab here:
WARNING:rpy2.rinterface_lib.callbacks:R[write to console]: Error in library(ggspatial) : there is no package called ‘ggspatial’

WARNING:rpy2.rinterface_lib.callbacks:R[write to console]: In addition:
WARNING:rpy2.rinterface_lib.callbacks:R[write to console]: Warning messages:

WARNING:rpy2.rinterface_lib.callbacks:R[write to console]: 1:
WARNING:rpy2.rinterface_lib.callbacks:R[write to console]: In install.packages("ggspatial") :
WARNING:rpy2.rinterface_lib.callbacks:R[write to console]:

WARNING:rpy2.rinterface_lib.callbacks:R[write to console]: installation of package ‘units’ had non-zero exit status

WARNING:rpy2.rinterface_lib.callbacks:R[write to console]: 2:
WARNING:rpy2.rinterface_lib.callbacks:R[write to console]: In install.packages("ggspatial") :
WARNING:rpy2.rinterface_lib.callbacks:R[write to console]:

WARNING:rpy2.rinterface_lib.callbacks:R[write to console]: installation of package ‘sf’ had non-zero exit status

WARNING:rpy2.rinterface_lib.callbacks:R[write to console]: 3:
WARNING:rpy2.rinterface_lib.callbacks:R[write to console]: In install.packages("ggspatial") :
WARNING:rpy2.rinterface_lib.callbacks:R[write to console]:

WARNING:rpy2.rinterface_lib.callbacks:R[write to console]: installation of package ‘ggspatial’ had non-zero exit status

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

RRuntimeError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/rpy2/ipython/rmagic.py in eval(self, code)
267 # Need the newline in case the last line in code is a comment.
--> 268 value, visible = ro.r("withVisible({%s\n})" % code)
269 except (ri.embedded.RRuntimeError, ValueError) as exception:

10 frames
/usr/local/lib/python3.7/dist-packages/rpy2/robjects/init.py in call(self, string)
437 p = rinterface.parse(string)
--> 438 res = self.eval(p)
439 return conversion.rpy2py(res)

/usr/local/lib/python3.7/dist-packages/rpy2/robjects/functions.py in call(self, *args, **kwargs)
198 return (super(SignatureTranslatedFunction, self)
--> 199 .call(*args, **kwargs))
200

/usr/local/lib/python3.7/dist-packages/rpy2/robjects/functions.py in call(self, *args, **kwargs)
124 new_kwargs[k] = conversion.py2rpy(v)
--> 125 res = super(Function, self).call(*new_args, **new_kwargs)
126 res = conversion.rpy2py(res)

/usr/local/lib/python3.7/dist-packages/rpy2/rinterface_lib/conversion.py in _(*args, **kwargs)
44 def _(*args, **kwargs):
---> 45 cdata = function(*args, **kwargs)
46 # TODO: test cdata is of the expected CType

/usr/local/lib/python3.7/dist-packages/rpy2/rinterface.py in call(self, *args, **kwargs)
679 if error_occured[0]:
--> 680 raise embedded.RRuntimeError(_rinterface._geterrmessage())
681 return res

RRuntimeError: Error in library(ggspatial) : there is no package called ‘ggspatial’

During handling of the above exception, another exception occurred:

RInterpreterError Traceback (most recent call last)
in
----> 1 get_ipython().run_cell_magic('R', '', 'library(ggplot2)\nlibrary(ggmap)\nlibrary(maps)\nlibrary(mapdata)\nlibrary(ggspatial)\n')

/usr/local/lib/python3.7/dist-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
2357 with self.builtin_trap:
2358 args = (magic_arg_s, cell)
-> 2359 result = fn(*args, **kwargs)
2360 return result
2361

in R(self, line, cell, local_ns)

/usr/local/lib/python3.7/dist-packages/IPython/core/magic.py in (f, *a, **k)
185 # but it's overkill for just that one bit of state.
186 def magic_deco(arg):
--> 187 call = lambda f, *a, **k: f(*a, **k)
188
189 if callable(arg):

/usr/local/lib/python3.7/dist-packages/rpy2/ipython/rmagic.py in R(self, line, cell, local_ns)
781 if not e.stdout.endswith(e.err):
782 print(e.err)
--> 783 raise e
784 finally:
785 if self.device in ['png', 'svg']:

/usr/local/lib/python3.7/dist-packages/rpy2/ipython/rmagic.py in R(self, line, cell, local_ns)
761 return_output = False
762 else:
--> 763 text_result, result, visible = self.eval(code)
764 text_output += text_result
765 if visible:

/usr/local/lib/python3.7/dist-packages/rpy2/ipython/rmagic.py in eval(self, code)
271 warning_or_other_msg = self.flush()
272 raise RInterpreterError(code, str(exception),
--> 273 warning_or_other_msg)
274 text_output = self.flush()
275 return text_output, value, visible[0]

RInterpreterError: Failed to parse and evaluate line 'library(ggplot2)\nlibrary(ggmap)\nlibrary(maps)\nlibrary(mapdata)\nlibrary(ggspatial)\n'.
R error message: 'Error in library(ggspatial) : there is no package called ‘ggspatial’'

@paleolimbot
Copy link
Owner

Hmm...do you get the output of install.packages("ggspatial")? My guess is that one of the dependencies failed to install.

@S-AQ
Copy link

S-AQ commented Nov 29, 2022

Yes the problem is with rjson which is in prettymapr, which is in turn used by rosm.

Installing package into/home/saquist/R/x86_64-pc-linux-gnu-library/3.6’
(aslibis unspecified)
Warning in install.packages :
  dependencyrjsonis not available
also installing the dependenciesprettymapr’, ‘rosmtrying URL 'https://cloud.r-project.org/src/contrib/prettymapr_0.2.4.tar.gz'
Content type 'application/x-gzip' length 871428 bytes (851 KB)
==================================================
downloaded 851 KB

trying URL 'https://cloud.r-project.org/src/contrib/rosm_0.2.6.tar.gz'
Content type 'application/x-gzip' length 442336 bytes (431 KB)
==================================================
downloaded 431 KB

trying URL 'https://cloud.r-project.org/src/contrib/ggspatial_1.1.7.tar.gz'
Content type 'application/x-gzip' length 2233717 bytes (2.1 MB)
==================================================
downloaded 2.1 MB

ERROR: dependencyrjsonis not available for packageprettymapr* removing/home/saquist/R/x86_64-pc-linux-gnu-library/3.6/prettymaprWarning in install.packages :
  installation of packageprettymaprhad non-zero exit status
ERROR: dependenciesrjson’, ‘prettymaprare not available for packagerosm* removing/home/saquist/R/x86_64-pc-linux-gnu-library/3.6/rosmWarning in install.packages :
  installation of packagerosmhad non-zero exit status
ERROR: dependencyrosmis not available for packageggspatial* removing/home/saquist/R/x86_64-pc-linux-gnu-library/3.6/ggspatialWarning in install.packages :
  installation of packageggspatialhad non-zero exit status

The downloaded source packages are in/tmp/RtmpheG11v/downloaded_packages> install.packages('prettymapr')
Installing package into/home/saquist/R/x86_64-pc-linux-gnu-library/3.6’
(aslibis unspecified)
Warning in install.packages :
  dependencyrjsonis not available
trying URL 'https://cloud.r-project.org/src/contrib/prettymapr_0.2.4.tar.gz'
Content type 'application/x-gzip' length 871428 bytes (851 KB)
==================================================
downloaded 851 KB

ERROR: dependencyrjsonis not available for packageprettymapr* removing/home/saquist/R/x86_64-pc-linux-gnu-library/3.6/prettymaprWarning in install.packages :
  installation of packageprettymaprhad non-zero exit status

The downloaded source packages are in/tmp/RtmpheG11v/downloaded_packages

@paleolimbot
Copy link
Owner

Hmm...it looks like 'rjson' is still on CRAN. Perhaps because it's an old-ish version of R there are no binaries? You may have to try either updating R or installing via RStudio Package Manager, which builds binaries for Windows for older versions of R than version 4.1.

@S-AQ
Copy link

S-AQ commented Dec 9, 2022

You are right, on the machine I had the error, I have R with version 3.6.3 (2020-02-29), while on my laptop I have R with version 4.2.0 (2022-04-22 ucrt), and that works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants