I've been using QGIS for a while and haven't had any major issues so far, but now I am getting the following Python error messages and certain plugins won't work. Any Ideas?

Failed to open Python console:

Traceback (most recent call last):
  File "", line 2, in 
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/console/console.py", line 46, in show_console
    _console = PythonConsole(parent)
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/console/console.py", line 83, in __init__
    self.console = PythonConsoleWidget(self)
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/console/console.py", line 109, in __init__
    self.shell = ShellScintilla(self)
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/console/console_sci.py", line 86, in __init__
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/console/console_sci.py", line 141, in refreshSettingsShell
TypeError: setCaretForegroundColor(self, QColor): argument 1 has unexpected type 'unicode'

Python version:
2.7.10 (default, Jul 30 2016, 18:31:42) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]

QGIS version:
2.18.0 'Las Palmas', exported

Python path:
['/Users/Harry/.qgis2/python/plugins/processing', '/Applications/QGIS.app/Contents/MacOS/../Resources/python', u'/Users/Harry/.qgis2/python', u'/Users/Harry/.qgis2/python/plugins', '/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins', '/Library/Frameworks/SQLite3.framework/Versions/C/Python/2.7', '/Library/Frameworks/GEOS.framework/Versions/3/Python/2.7/site-packages', '/Library/Python/2.7/site-packages/scipy-override', '/Library/Python/2.7/site-packages/numpy-override', '/Library/Python/2.7/site-packages/matplotlib-override', '/Library/Frameworks/GDAL.framework/Versions/2.1/Python/2.7/site-packages', '/Library/Python/2.7/site-packages/PySAL-1.12.0-py2.7.egg', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', u'/Users/Harry/.qgis2//python', '/Users/Harry/.qgis2/python/plugins/gearthview/ext-libs', u'/Users/Harry/Documents/Work/RCA/10.yr_2/ADS_3/mapping/qgs']

I also get this error when trying to run Cartographic Line Generalization plugin:

2016-12-07T15:01:02 1   
Traceback (most recent call last):
File "/Users/Harry/.qgis2/python/plugins/CartoLineGen-master/cartolinegen.py", line 210, in run
File "/Users/Harry/.qgis2/python/plugins/CartoLineGen-master/cartolinegen.py", line 234, in count_vertices
                feat = inLayer.getFeatures()
AttributeError: 'QgsRasterLayer' object has no attribute 'getFeatures'
  • Have you tried reinstalling it? – user32496 Dec 7 '16 at 1:58
  • Mabe related: stackoverflow.com/questions/37842948/… – AndreJ Dec 7 '16 at 9:04
  • I got similar errors installing 2.18.15 on Win 7 today. So I backed down to 2.18.14 and the errors went away. – Pooneil Jan 4 '18 at 21:49

I've had the same issue happen twice on QGIS 2.18 "Las Palmas" on macOS Sierra 10.12.2. Something in the preferences file occasionally gets corrupted. I haven't tracked down which setting causes the problem but if you move or delete the plist preferences file, QGIS recreates it on the next launch and the console works. The downside is you lose all of your GUI customizations. Things like plugins and scripts remain intact as they are stored in your user folder.

The QGIS plist file can be found at:


It's an XML file so if you move it, you can refer to it for various settings. I plan to do a diff with a corrupted file and figure out what's going on. I can't trace the exact cause but I'm usually tinkering with PyQGIS.

| improve this answer | |

Had this exact bug happen to me in 2.18.2 and, after installation, in 2.18.14 on Mac High Sierra 10.13.2. Removing the plist file solved the issue.

Issue is repeatedly triggered with the following steps:

  1. open the python console
  2. Show the editor window
  3. open a python script file
  4. right click in the editor window and select options
  5. change the text size.

As soon as you hit ok:

Traceback (most recent call last):
File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/console/console.py", line 691, in openSettings
File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/console/console_sci.py", line 141, in refreshSettingsShell
TypeError: setCaretForegroundColor(self, QColor): argument 1 has unexpected type 'unicode'
| improve this answer | |

Daniel's order of operations caused the same error for me.

I found a solution for this that doesn't wipe all preferences, but I'm sure that there's a more precise one:

Open the .plist GeospatialPython.com mentioned (thanks!) in a text editor and search for all instances of


...and remove it, and their 'string' (the entire line above it), as well.

That open-bracketed '@Variant(' looks wonky, and something in the app is inserting it in there when console interface preference changes are made.

| improve this answer | |

Your Answer

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

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