Bug report #21770

"Python support will be disabled" if using non-ascii characters

Added by Morten Sickel over 5 years ago. Updated over 5 years ago.

Status:Feedback
Priority:Normal
Assignee:-
Category:Python bindings / sipify
Affected QGIS version:3.6.1 Regression?:No
Operating System:Windows 10 - but probably OS independent Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:29585

Description

When starting qgis 3.6.1 on windows 10 after booting, I am met with

Couldn't load qgis.user.
Python support will be disabled.
traceback.print_exception() failed
Python version:
QGIS version:
3.6.1-Noosa 'Noosa', 2468226bc9
Python path:

Afterwards I got a new dialog with a traceback concluding with

"UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf8 in position 1437: invalid start byte"

The day before I had been writing an expression in python, I had put some comments in it in my native language, Norwegian, containing the letter 'ø'. Using the information in pythonpath in the 2nd dialog, I could find where the code was stored, open it in an editor and remove the comments. Then everything worked fine.

In windows, the offending file was "C:\Users\<username>\AppData\Roaming\QGIS\QGIS3\profiles\default\python\expressions\default.py" (left here mainly in case somebody googles for the same problem)

It should be expected that there could be non-ascii characters in expression code.

To reproduce the error:

Write an expression (mine was to fill inn some text in a box in a print layout) containing the letter 'ø'. Quit QGIS. When QGIS is opened, the above mentioned messages comes up.

Workaround: Catch the UnicodeDecodeError, tell in a friendly understandable way what is the problem and point to the file that has to be fixed.

Fix: Set up a python environment that allows utf-8 in .py files

History

#1 Updated by Giovanni Manghi over 5 years ago

  • Crashes QGIS or corrupts data changed from Yes to No
  • Status changed from Open to Feedback

I cannot replicate on 3.6.1 on Linux (using ã, ç, etc.).

Also available in: Atom PDF