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:

qgis_env <- set_env("C:/Program Files/QGIS 3.4")

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?

  • 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. – Saijin_Naib Feb 14 '20 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. – Glenn Stauffer Feb 17 '20 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. – Glenn Stauffer Feb 21 '20 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. – Glenn Stauffer Feb 21 '20 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 – Saijin_Naib Feb 21 '20 at 21:35

Your Answer

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

Browse other questions tagged or ask your own question.