I try to detect if my script is run from a QGIS instance (through the plugin) or from a standard python console. This detection will enable conditional imports of the required librairies which are different from a case to the other.
For conditional imports, I found here
try: import module except ImportError: import otherModule as module
and tried to adapt it for my use case but I can't raise a convenient error:
try: import processing except: # Load required libraries to run from python (!Unstable!) # See https://gis.stackexchange.com/questions/129915/cannot-run-standalone-qgis-script # for any improvements import os, sys, glob # Prepare the environment ... # See https://gis.stackexchange.com/questions/129915/cannot-run-standalone-qgis-script
Returns me following error : QPixmap: Must construct a QApplication before a QPaintDevice
and does not instead enters the except clause what is sad.