Bug report #15293

Updated by Giovanni Manghi over 3 years ago

The bug is about character encoding when using geoprocessing algorithm from the toolbox, using PyQGIS.



It affects 2.16 but also previous versions (Windows).



The bug is not reproducable in 2.4 (Linux Debian)



However, the behaviour is a slightly different in 2.16, so I am creating the issue for 2.16.



Here are the steps for reproducing the bug:



------------------



* Installing QGIS 2.16 from osgeo4w.

* Installing my Python plugin (the plugin is in C:\\OSGeo4W64\\apps\\qgis\\python\\plugins\\myplugin)

* Run the plugin. There, the output has correct encoding (same as input, UTF-8).

* Exit QGIS



* Re-Open QGIS

- ERROR:

<pre>

An error occurred during execution of following code:

import pyplugin_installer



UnicodeEncodeError: 'ascii' codec can't encode character u'\\xe9' in position 12: ordinal not in range(128)



Python version:

2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]



QGIS version:

2.16.0-Nødebo 'Nødebo', d0b3e39



Python path:

['C:/OSGEO4~1/apps/qgis/./python/plugins\\\\processing', 'C:/OSGEO4~1/apps/qgis/./python', u'C:/Users/Gobtron/.qgis2/python', u'C:/Users/Gobtron/.qgis2/python/plugins', 'C:/OSGEO4~1/apps/qgis/./python/plugins', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\matplotlib-1.3.1-py2.7-win-amd64.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\

ose-1.3.3-py2.7.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\tornado-4.0.1-py2.7-win-amd64.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\backports.ssl_match_hostname-3.4.0.2-py2.7.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\certifi-14.05.14-py2.7.egg', 'c:\\\\osgeo4~1\\\\apps\\\\python27\\\\lib\\\\site-packages\\\\python_dateutil-2.1-py2.7.egg', 'C:\\\\Python27\\\\ArcGIS10.2', 'C:\\\\OSGEO4~1\\\\bin\\\\python27.zip', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\DLLs', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\plat-win', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\lib-tk', 'C:\\\\OSGEO4~1\\\\bin', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\PIL', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\jinja2-2.7.2-py2.7.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\markupsafe-0.23-py2.7-win-amd64.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\pytz-2012j-py2.7.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\win32', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\win32\\\\lib', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\Pythonwin', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\Shapely-1.2.18-py2.7-win-amd64.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\wx-2.8-msw-unicode', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\xlrd-0.9.2-py2.7.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\xlwt-0.7.5-py2.7.egg', u'C:/Users/Gobtron/.qgis2//python']

</pre>



* Another error:

<pre>

An error occurred during execution of following code:

pyplugin_installer.initPluginInstaller()



Traceback (most recent call last):

File "", line 1, in

NameError: name 'pyplugin_installer' is not defined



Python version:

2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]



QGIS version:

2.16.0-Nødebo 'Nødebo', d0b3e39



Python path:

['C:/OSGEO4~1/apps/qgis/./python/plugins\\\\processing', 'C:/OSGEO4~1/apps/qgis/./python', u'C:/Users/Gobtron/.qgis2/python', u'C:/Users/Gobtron/.qgis2/python/plugins', 'C:/OSGEO4~1/apps/qgis/./python/plugins', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\matplotlib-1.3.1-py2.7-win-amd64.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\

ose-1.3.3-py2.7.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\tornado-4.0.1-py2.7-win-amd64.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\backports.ssl_match_hostname-3.4.0.2-py2.7.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\certifi-14.05.14-py2.7.egg', 'c:\\\\osgeo4~1\\\\apps\\\\python27\\\\lib\\\\site-packages\\\\python_dateutil-2.1-py2.7.egg', 'C:\\\\Python27\\\\ArcGIS10.2', 'C:\\\\OSGEO4~1\\\\bin\\\\python27.zip', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\DLLs', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\plat-win', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\lib-tk', 'C:\\\\OSGEO4~1\\\\bin', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\PIL', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\jinja2-2.7.2-py2.7.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\markupsafe-0.23-py2.7-win-amd64.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\pytz-2012j-py2.7.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\win32', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\win32\\\\lib', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\Pythonwin', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\Shapely-1.2.18-py2.7-win-amd64.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\wx-2.8-msw-unicode', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\xlrd-0.9.2-py2.7.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\xlwt-0.7.5-py2.7.egg', u'C:/Users/Gobtron/.qgis2//python']

</pre>



* Then QGIS opens, but my plugin is absent

* If I open 'Manage and Install Plugins...', I get this error:

<pre>

An error occurred during execution of following code:

pyplugin_installer.instance().showPluginManagerWhenReady()



Traceback (most recent call last):

File "", line 1, in

NameError: name 'pyplugin_installer' is not defined



Python version:

2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]



QGIS version:

2.16.0-Nødebo 'Nødebo', d0b3e39



Python path:

['C:/OSGEO4~1/apps/qgis/./python/plugins\\\\processing', 'C:/OSGEO4~1/apps/qgis/./python', u'C:/Users/Gobtron/.qgis2/python', u'C:/Users/Gobtron/.qgis2/python/plugins', 'C:/OSGEO4~1/apps/qgis/./python/plugins', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\matplotlib-1.3.1-py2.7-win-amd64.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\

ose-1.3.3-py2.7.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\tornado-4.0.1-py2.7-win-amd64.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\backports.ssl_match_hostname-3.4.0.2-py2.7.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\certifi-14.05.14-py2.7.egg', 'c:\\\\osgeo4~1\\\\apps\\\\python27\\\\lib\\\\site-packages\\\\python_dateutil-2.1-py2.7.egg', 'C:\\\\Python27\\\\ArcGIS10.2', 'C:\\\\OSGEO4~1\\\\bin\\\\python27.zip', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\DLLs', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\plat-win', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\lib-tk', 'C:\\\\OSGEO4~1\\\\bin', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\PIL', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\jinja2-2.7.2-py2.7.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\markupsafe-0.23-py2.7-win-amd64.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\pytz-2012j-py2.7.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\win32', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\win32\\\\lib', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\Pythonwin', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\Shapely-1.2.18-py2.7-win-amd64.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\wx-2.8-msw-unicode', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\xlrd-0.9.2-py2.7.egg', 'C:\\\\OSGEO4~1\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\xlwt-0.7.5-py2.7.egg', u'C:/Users/Gobtron/.qgis2//python']

</pre>



* Exit QGIS

* Re-Open QGIS

* Open 'Manage and Install Plugin...'

* My plugin is uninstalled

* Re-install my plugin

* Run the plugin

* Encoding is broken and different from source (UTF-8).

Back