I'm getting an error about an operation involving a QPyNullVariant:

TypeError: unsupported operand type(s) for *: 'QPyNullVariant' and 'float'

I wanted to put a check into my code to skip these values. However, my IDE (Eclipse) [and more over the terminal Python interface] doesn't recognize this as part of the PyQt4.QtCore module whereas it seems fine within QGIS. I have updated all my packages and restarted my computer.

import PyQt4.QtCore as pyqt
import sys
print(sys.version)    #1
print(pyqt.__file__)  #2
pyqt.QPyNullVariant   #3

in all cases this produces the following out put for 1 and 2:

2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2]


However in Eclipse (with PyDev) and in the terminal interpreter the call to PyQt module for a QPyNullVariant attribute fails:

AttributeError: 'module' object has no attribute 'QPyNullVariant'

whereas in the QGIS python interpreter you get:

<class 'PyQt4.QtCore.QPyNullVariant'>


  • Further debugging and a try/except show that it evaluates as equal to None which is good for a simple test, but... I'm still puzzled.
    – Kris
    Jan 14, 2016 at 16:12


Browse other questions tagged or ask your own question.