0

I am trying to use the RQGIS3 package to access QGIS3 functions from R, and although briefly I had things working (mostly), running the following code:

library(RQGIS3)
qgis_env <- set_env("C:/Program Files/QGIS 3.4")
qgis_session_info(qgis_env=qgis_env)</code>

now produces the following error:

Error in py_get_attr_impl(x, name, silent) : 
  AttributeError: module '__main__' has no attribute 'RQGIS3'

I'm not sure what changed. Another post suggested that the order in which packages were loaded determined whether this error cropped up, but in my case, I have not even loaded any other packages. I am pretty new at using RQGIS(3), and know next to nothing about Python.

I am using QGIS 3.4.7, and R 3.5.0 (I will get out IT staff to upgrade R next week to see if that fixes things).

Any thoughts what else might be going on here?

6
  • Get your IT staff to update QGIS to a supported build, as well. Either 3.4.15-1 LTS (about to be deprecated) or 3.10.2-2. Feb 14, 2020 at 21:46
  • 1
    I have not had a chance yet to update QGIS, but I got R updated to 3.6.1 (the latest approved version for me). But I can't install RQGIS3 on it because remotes:::install.github() throws an error because reticulate expects R 3.6.2, even though I specify R_REMOTES_NO_ERRORS_FROM_WARNINGS="true" as suggested at <github.com/r-lib/remotes#environment-variables>. I'll report back when I get this resolved. Feb 17, 2020 at 16:55
  • I did Sys.setenv(R_REMOTES_NO_ERRORS_FROM_WARNINGS=TRUE) and then QGIS3 installed just fine (mostly). There were some warnings that links to SpatialPointsDataframes (Polygons, Lines) did not exist and were being treated as a topic. I also updated QGIS to 3.4.11 (the latest approved version in our organization) and it made no difference. My operating system is WIndows 10. I have a laptop with Linux Mint, and QGIS 3.4.13, and things seem to work fine over there. Feb 21, 2020 at 21:19
  • One other note: The above error does not appear when I invoke native:zonalhistogram in RStudio as opposed to RGui, and it seems to produce the correct results. But in RStudio a bunch of other warnings appear (Deprecation warnings about invalid escape sequence, and about importing the ABCs from 'collections' instead of from 'collections.abc'), and there is a warning about ERROR 4: Unable to open EPSG support file gcs.csv. Feb 21, 2020 at 21:20
  • I can only strongly recommend you use a supported version to test against, again. I'll see if I can replicate this on a personal machine with W10/QGIS 3.10.2-2 Feb 21, 2020 at 21:35

1 Answer 1

1

Just to wrap this up over a year later. I never did resolve this issue, even after I updated to QGIS 3.16. However, in the meantime, I read that RQGIS3 is no longer maintained, and it's use is discouraged. Instead, there is now a command line executable called qgis_process in QGIS (3.14 and later), and a corresponding R package called qgisprocess (read about it here) that does much of what RQGIS3 did, and it does not rely on Python. I've tried it, and it did what I wanted, and it has rendered moot the issue I described above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.