0

I'm having this strange error in QGIS 2.2 for OS X while trying to run the raster merge tool (in the Raster - Miscellaneous - Merge). This happens just by clicking on the "Select" button to choose the files that will be merged.

Does anyone has an idea of what can be the problem? Is it due to the Python version I have installed

Thanks!

An error has occured while executing Python code:

Traceback (most recent call last):
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/GdalTools/tools/doMerge.py", line 92, in fillInputFilesEdit
    files = Utils.FileDialog.getOpenFileNames(self, self.tr( "Select the files to Merge" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/GdalTools/tools/GdalTools_utils.py", line 394, in getOpenFileNames
    return self.getDialog(parent, caption, QFileDialog.AcceptOpen, QFileDialog.ExistingFiles, filter, selectedFilter, useEncoding)
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/GdalTools/tools/GdalTools_utils.py", line 351, in getDialog
    dialog.selectNameFilter(selectedFilter[0])
TypeError: QFileDialog.selectNameFilter(QString): argument 1 has unexpected type 'QPyNullVariant'

Python version:
2.7.5 (default, Aug 25 2013, 00:04:04) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]


QGIS version:
2.2.0-Valmiera Valmiera, 

Python path: ['/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing', '/Users/gds506/.qgis2/python/plugins/LecoS', '/Applications/QGIS.app/Contents/MacOS/../Resources/python', u'/Users/gds506/.qgis2/python', u'/Users/gds506/.qgis2/python/plugins', '/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins', '/Library/Frameworks/SQLite3.framework/Versions/B/Python/2.7', '/Library/Frameworks/GEOS.framework/Versions/3/Python/2.7', '/Library/Python/2.7/site-packages/numpy-override', '/Library/Python/2.7/site-packages/matplotlib-override', '/Library/Frameworks/GDAL.framework/Versions/1.10/Python/2.7/site-packages', '/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/Extras/lib/python', '/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', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages', '/Library/Python/2.7/site-packages/PIL', '/Users/gds506/.qgis2/python/plugins/mmqgis/forms', '/Applications/QGIS.app/Contents/Resources/python/plugins/fTools/tools']

1 Answer 1

1

This is a bug and needs addressed. It stems from the recent transition from v1 to v2 of the string API in PyQt (happened with the QGIS 2.0 release).

TypeError: QFileDialog.selectNameFilter(QString): argument 1 has unexpected type 'QPyNullVariant'

This error implies that the name filter for the dialog is not receiving a list, or may be a list including an empty string or null/None value.

After opening the file in question, GdalTools_utils.py, I noticed an invalid Python None comparison operator.

Try editing the following file (save a backup copy first):

/Applications/QGIS.app/Contents/Resources/python/plugins/GdalTools/tools/GdalTools_utils.py

replace the two occurrences of:

selectedFilter != None

with:

selectedFilter is not None

See if that makes a difference. If not restore the file's original content and file an issue report via http://issues.qgis.org, and make note of this page.

Regardless of the error above, there is another issue that may present. That QFileDialog.selectNameFilter(QString) command should be receiving a large semicolon-delimited list of the available GDAL raster formats, not a QPyNullVariant, in the first place.

Verify you have GDAL raster formats reporting properly by going to QGIS -> Preferences menu item and then opening the GDAL section. It should list a bunch of formats. If not, there is a larger issue with regards to the GDAL install here.


Update: Also try explicitly defining the return type for QSettings, as noted in the current QGIS bug report concerning this issue.

1
  • The issue was solved by defining the return type for QSettings as noted on the link you shared. Thanks dakcarto! Commented Mar 6, 2014 at 1:35

Your Answer

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

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