2

I've experienced at times that the qgis2web plugin does not work. I have received this python error message:

Ha ocurrido un error mientras se ejecutaba el código de Python:

Traceback (most recent call last):
  File "C:/Users/u54202/.qgis2/python/plugins\qgis2web\qgis2web.py", line 51, in run
    dlg = MainDialog(self.iface)
  File "C:/Users/u54202/.qgis2/python/plugins\qgis2web\maindialog.py", line 55, in __init__
    self.previewMap()
  File "C:/Users/u54202/.qgis2/python/plugins\qgis2web\maindialog.py", line 97, in previewMap
    MainDialog.previewOL3(self)
  File "C:/Users/u54202/.qgis2/python/plugins\qgis2web\maindialog.py", line 222, in previewOL3
    previewFile = writeOL(self.iface, layers, groups, popup, visible, json, cluster, labels, params, utils.tempFolder())
  File "C:/Users/u54202/.qgis2/python/plugins\qgis2web\olwriter.py", line 53, in writeOL
    exportLayers(layers, folder, precision, optimize, usedFields)
  File "C:/Users/u54202/.qgis2/python/plugins\qgis2web\utils.py", line 60, in exportLayers
    reducePrecision = re.compile(r"([0-9]+\.[0-9]{%s})([0-9]+)" % str(int(precision)))
ValueError: invalid literal for int() with base 10: ''


Versión de Python:
2.7.4 (default, Apr  6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)]


Versión de QGIS:
2.8.2-Wien Wien, 1b929ef

Ruta de Python: ['C:/PROGRA~1/QGISWI~1/apps/qgis/./python/plugins\\processing', 'C:/Users/u54202/.qgis2/python/plugins\\postgis_geoprocessing', 'C:\\Users\\u54202\\.qgis2\\python\\plugins\\GeoCoding\\libs', 'C:/PROGRA~1/QGISWI~1/apps/qgis/./python', u'C:/Users/u54202/.qgis2/python', u'C:/Users/u54202/.qgis2/python/plugins', 'C:/PROGRA~1/QGISWI~1/apps/qgis/./python/plugins', 'C:\\PROGRA~1\\QGISWI~1\\bin\\python27.zip', 'C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\DLLs', 'C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib', 'C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\plat-win', 'C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\lib-tk', 'C:\\PROGRA~1\\QGISWI~1\\bin', 'C:\\PROGRA~1\\QGISWI~1\\apps\\Python27', 'C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages', 'C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\PIL', 'C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\jinja2-2.7.2-py2.7.egg', 'C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\markupsafe-0.23-py2.7-win32.egg', 'C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\python_dateutil-2.2-py2.7.egg', 'C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\pytz-2014.2-py2.7.egg', 'C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\win32', 'C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\win32\\lib', 'C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\Pythonwin', 'C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\Shapely-1.2.18-py2.7-win32.egg', 'C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\six-1.6.1-py2.7.egg', 'C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\wx-2.8-msw-unicode', u'C:/Users/u54202/.qgis2//python', 'C:\\Users\\u54202\\.qgis2\\python\\plugins', 'C:\\PROGRA~1\\QGISWI~1\\apps\\qgis\\python\\plugins\\fTools\\tools', 'C:\\Users\\u54202\\.qgis2\\python\\plugins\\mmqgis/forms', 'C:\\Users\\u54202\\.qgis2\\python\\plugins']

The other day a solved this problem from the python console but today is not working:

from PyQt4.QtCore import QSettings
QSettings().remove("Extent")
QSettings().remove("Base layer")
QSettings().remove("Template")

Edit:

OK, It worked... but again I have the same problem: python error. But this time this syntax does not worked.

Why is this still happening?

Traceback (most recent call last): File "C:/Users/u54202/.qgis2/python/plugins\qgis2web\qgis2web.py", line 51, in run dlg = MainDialog(self.iface) File "C:/Users/u54202/.qgis2/python/plugins\qgis2web\maindialog.py", line 55, in init self.previewMap() File "C:/Users/u54202/.qgis2/python/plugins\qgis2web\maindialog.py", line 99, in previewMap MainDialog.previewLeaflet(self) File "C:/Users/u54202/.qgis2/python/plugins\qgis2web\maindialog.py", line 229, in previewLeaflet previewFile = writeLeaflet(self.iface, utils.tempFolder(), 500, 700, 1, layers, visible, "", cluster, "", "", "", labels, 0, 0, json, params, popup) File "C:/Users/u54202/.qgis2/python/plugins\qgis2web\leafletWriter.py", line 203, in writeLeaflet if str(field) == "icon_exp": UnicodeEncodeError: 'ascii' codec can't encode character u'\xed' in position 1: ordinal not in range(128)

Versión de Python: 2.7.4 (default, Apr 6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)]

Versión de QGIS: 2.8.2-Wien Wien, 1b929ef

Ruta de Python: ['C:/PROGRA~1/QGISWI~1/apps/qgis/./python/plugins\processing', 'C:/Users/u54202/.qgis2/python/plugins\postgis_geoprocessing', 'C:\Users\u54202\.qgis2\python\plugins\GeoCoding\libs', 'C:/PROGRA~1/QGISWI~1/apps/qgis/./python', u'C:/Users/u54202/.qgis2/python', u'C:/Users/u54202/.qgis2/python/plugins', 'C:/PROGRA~1/QGISWI~1/apps/qgis/./python/plugins', 'C:\PROGRA~1\QGISWI~1\bin\python27.zip', 'C:\PROGRA~1\QGISWI~1\apps\Python27\DLLs', 'C:\PROGRA~1\QGISWI~1\apps\Python27\lib', 'C:\PROGRA~1\QGISWI~1\apps\Python27\lib\plat-win', 'C:\PROGRA~1\QGISWI~1\apps\Python27\lib\lib-tk', 'C:\PROGRA~1\QGISWI~1\bin', 'C:\PROGRA~1\QGISWI~1\apps\Python27', 'C:\PROGRA~1\QGISWI~1\apps\Python27\lib\site-packages', 'C:\PROGRA~1\QGISWI~1\apps\Python27\lib\site-packages\PIL', 'C:\PROGRA~1\QGISWI~1\apps\Python27\lib\site-packages\jinja2-2.7.2-py2.7.egg', 'C:\PROGRA~1\QGISWI~1\apps\Python27\lib\site-packages\markupsafe-0.23-py2.7-win32.egg', 'C:\PROGRA~1\QGISWI~1\apps\Python27\lib\site-packages\python_dateutil-2.2-py2.7.egg', 'C:\PROGRA~1\QGISWI~1\apps\Python27\lib\site-packages\pytz-2014.2-py2.7.egg', 'C:\PROGRA~1\QGISWI~1\apps\Python27\lib\site-packages\win32', 'C:\PROGRA~1\QGISWI~1\apps\Python27\lib\site-packages\win32\lib', 'C:\PROGRA~1\QGISWI~1\apps\Python27\lib\site-packages\Pythonwin', 'C:\PROGRA~1\QGISWI~1\apps\Python27\lib\site-packages\Shapely-1.2.18-py2.7-win32.egg', 'C:\PROGRA~1\QGISWI~1\apps\Python27\lib\site-packages\six-1.6.1-py2.7.egg', 'C:\PROGRA~1\QGISWI~1\apps\Python27\lib\site-packages\wx-2.8-msw-unicode', u'C:/Users/u54202/.qgis2//python', 'C:\Users\u54202\.qgis2\python\plugins', 'C:\PROGRA~1\QGISWI~1\apps\qgis\python\plugins\fTools\tools', 'C:\Users\u54202\.qgis2\python\plugins\mmqgis/forms']

1
  • Sorry, I forgot. I have the latest version, since today. Still not working.
    – Evelyn
    Jul 17, 2015 at 14:28

2 Answers 2

4

Do the same in the console, but add qgis2web/ before each param name, eg:

QSettings().remove("qgis2web/Extent") QSettings().remove("qgis2web/Base layer") QSettings().remove("qgis2web/Template")

Since that error was caused by Precision, also try:

QSettings().remove("qgis2web/Precision")
2
  • Thank you so much!!! My problem is solved! I guess the key was add "qgis2web". Thanks again
    – Evelyn
    Jul 17, 2015 at 16:38
  • Ok, I understand now. Sorry, I did not know
    – Evelyn
    Jul 21, 2015 at 11:18
4

Ah, this looks like an encoding error. I need to patch the plugin to replace str() with unicode(). I'm away for two weeks, so for the moment, change leafletWriter.py line 203 from:

if str(field) == "icon_exp":

to:

if unicode(field) == "icon_exp":

Do the same with any similar errors. And if it works, please do create a pull request on Github.

Edit: it's worth naming your layers and properties with simple characters only. There are probably other bits of code which will fail with eg accented characters.

1
  • I've committed this change to master, but I've not tested it yet. Try that and let us know if that fixes the problem. Aug 3, 2015 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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