1

I am trying to establish a QGIS3 custom application under Linux (Arch Antergos), according to the documentation (section 1.4.2) the following should work (but it doesn't). I executed the subsequent code from the system command line:

export PYTHONPATH=/usr/share/qgis/python
export LD_LIBRARY_PATH=/usr/lib
python3
from qgis.core import *
QgsApplication.setPrefixPath("/usr/bin/qgis", True)
# running showSettings() also does not return the expected results
# QgsApplication.showSettings()
# running QgsApplication.setPrefixPath("/usr", True) looks better with showSettings(), however, fails also in the next step
qgs = QgsApplication([], True)
qgs.initQgis()

After running qgs = QgsApplication([], True) Python is terminated with following error message:

malloc_consolidate(): invalid chunk size
[1]    5581 abort (core dumped)  python3

The same code worked with QGIS 2.18.

Has something changed or am I missing something?

  • Seems to be an Arch Linux issue. I have tested the same code successfully using a Docker container built on rocker and thus using a Debian Linux distribution – Jannes Nov 23 '18 at 13:28
1

I had the same issue after recent KDE update and I found a fix.

The malloc error come from de QgsApplication([ ]) empty list.

To prevent this you can use qgs = QgsApplication([b''], False) qgs.setPrefixPath('/usr') qgs.initQgis() If you need the GUI the bool should be True and I'm not sure but the array should contain something like the parent QObject, you could look at the QApplication constructor in Qt doc.

Works on Debian testing. Not tested on Arch but I think this is the same problem.

  • Thanks, this works! However, running qgs = QgsApplication([b''], True) throws following error/warning messages QSettings::value: Empty key passed QSettings::value: Empty key passed. This does not seem to affect usage when run from inside Python or R started from the terminal. However, doing the same from within RStudio crashes the R session. – Jannes Dec 27 '18 at 16:47
  • Also interesting, when switching to the virtual command line interface of Arch Linux (strg + alt + f6), QgsApplication([], True) also works. – Jannes Dec 27 '18 at 17:07
  • Yes this warning was already there with an empty list, it is normal. This empty byte trick is needed since a few months.. may be 3.4 – vidlb Dec 29 '18 at 12:40

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.