We have developed a few PyQGIS standalone applications that bring in PyQt5.Qtcore, PyQt5.QtGui, and qgis.core
to display map and do custom logics etc. The applications started with QGIS python 2.7 all the way to QGIS python 3.6, over time we found that it is getting increasingly difficult to get the libraries setup correctly and packaging the application.
I would like to emphasize that these are applications that are completely standalone without needing to open QGIS program, they are NOT run from inside QGIS's python console.
Now, it is QGIS 3.16 LTR with Python 3.8, after upgrade QGIS, our apps stopped working, this happens pretty much every time there is a new version of QGIS. The QGIS installation structure changed a lot with this new version (just like previous version changes), to name a few things for example, apps/qt5/include
and apps/qt5/doc
directories are no longer there, and the following imports are no longer working:
from PyQt5 import QtCore, QtGui
from PyQt5.QtGui import *
from PyQt5.QtWidgets import QApplication, QMainWindow, QUndoCommand, QUndoStack, QFileDialog, QVBoxLayout, QAction
from PyQt5.QtWidgets import QAbstractItemView, QMessageBox, QMenu, QInputDialog, QDockWidget
Does QGIS still intend to support standalone application development or should we abandon these apps and build plugins instead? I could NOT find an up-to-date programmer's guide for developing standalone applications, most of the PDF instruction files on the internet are for much older versions of QGIS.
A bit more information about our application setup. We develop using PyCharm on Windows 10 OS, and we install QGIS using its installer, not from package, for example, for this latest version, we used QGIS-OSGeo4W-3.16.11-1.msi
and install into C:\OSGeo4W64
directory, then in PyCharm, we set python interpreter to C:\OSGeo4W64\apps\Python39\python.exe
(the last version was pointing to Python36\python.exe
), this will pull in all packages that come with the QGIS software and this has been the way we've been developing the applications. This is because from past experience (since QGIS python 2.7), we have to use all python libraries/packages that come with QGIS inside its own installation directories, because it appears that the qgis.core is built with its own versions of every package that is included in QGIS software itself. We tried in the past to point to outside PyQt libraries and couldn't get qgis.core to work in standalone application until we reference everything back into QGIS software itself.
We look forward to hearing a more definitive answer and any migration tips/guide.