I am currently using R ver. 3.4.1 installed on C:\R\R-3.4.1, installed and loaded Packages: RQGIS, sp, raster. QGIS ver. 2.18.11 installed with OSGeo installer on C:\OSGeo4W64\apps\qgis.

In R I am trying to use the installed RQGIS package to enable QGIS functions via R as shown in the example of the packages GitHub page (https://github.com/jannes-m/RQGIS), I was following.

My environment is set to:

[1] "C:\\OSGeo4W64"
[1] "C:\\OSGeo4W64\\apps\\qgis"
[1] "C:\\OSGeo4W64\\apps\\qgis\\python\\plugins"

But unfortunately I always get errors at the following line of code:

find_algorithms(search_term = "([Pp]olygon)(centroid)")

Error in py_str_impl(object) : 
  UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 77807: ordinal not in range(128)
Error in py_call_impl(callable, dots$args, dots$keywords) : 
  AttributeError: 'file' object has no attribute 'getvalue'

Detailed traceback: 
  File "C:/R/library/reticulate/python\rpytools\output.py", line 14, in end_stdout_capture
    output = sys.stdout.getvalue()

I have already tried reinstalling QGIS, R and all depending packages for a couple of times.

Now I checked Spacedman's suggestions, see below.

For R:

> reticulate::py_config() 
python:         C:\OSGeo4W64\bin\python.exe 
libpython:      C:/OSGeo4W64/bin/python27.dll
pythonhome:     C:\OSGeo4W64\apps\Python27 
version:        2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] 
Architecture:   64bit 
numpy:          C:\OSGeo4W64\apps\Python27\lib\site-packages\numpy.               
 numpy_version:  1.12.1  
 python versions found:   

And in QGIS I entered:

import sys 


Unfortunately I still don't know how to get it up running correctly.

  • Looks like reticulate is causing the error. Do you have the latest CRAN version of reticulate? – pat-s Jul 23 '17 at 22:00
  • Yes, I do have the latest CRAN reticulate version installed. I even deleted the reticulate folder in my library directory and reinstalled the package. But still no success... – user19444 Jul 24 '17 at 7:25
  • Run reticulate::py_config() in R. Then in the QGIS python console do import sys and sys.executable. The sys.executable in QGIS should be the same as the python: value in the config. Edit your question and include those outputs. – Spacedman Jul 24 '17 at 8:31
  • Thank you for your Ideas. But I admit I don't know how to use the output your code produces, to correct my errors. I appreciate further advices. – user19444 Jul 24 '17 at 22:25
  • Right now I assume that your problem goes back to the unicode thing and has nothing to do with RQGIS. Have you tried to look for solutions for this problem? See for example stackoverflow.com/questions/9942594/… or gis.stackexchange.com/questions/59521/… – pat-s Jul 26 '17 at 10:23

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.