Skip to main content
added 2 characters in body
Source Link
Jochen Schwarze
  • 14.9k
  • 8
  • 54
  • 120

For anyone else that stumbles across this question, iI managed to solve the issue using a batch file with the following code:

cd C:\Program Files\QGIS 3.4\bin

qgis --project "path to .qgz project file" --code "path to .py python code file"

The gqisqgis bit in the second line needs to match whatever .bat file is run to open QGIS. forFor some users this was qgis-ltr. This launches qgisQGIS and opens a saved project, then runs the python script.

And my python script needed to start with the following to execute properly:

from qgis.core import *
import qgis.utils
from qgis.utils import iface

For anyone else that stumbles across this question, i managed to solve the issue using a batch file with the following code:

cd C:\Program Files\QGIS 3.4\bin

qgis --project "path to .qgz project file" --code "path to .py python code file"

The gqis bit in the second line needs to match whatever .bat file is run to open QGIS. for some users this was qgis-ltr. This launches qgis and opens a saved project, then runs the python script.

And my python script needed to start with the following to execute properly:

from qgis.core import *
import qgis.utils
from qgis.utils import iface

For anyone else that stumbles across this question, I managed to solve the issue using a batch file with the following code:

cd C:\Program Files\QGIS 3.4\bin

qgis --project "path to .qgz project file" --code "path to .py python code file"

The qgis bit in the second line needs to match whatever .bat file is run to open QGIS. For some users this was qgis-ltr. This launches QGIS and opens a saved project, then runs the python script.

And my python script needed to start with the following to execute properly:

from qgis.core import *
import qgis.utils
from qgis.utils import iface
Source Link

For anyone else that stumbles across this question, i managed to solve the issue using a batch file with the following code:

cd C:\Program Files\QGIS 3.4\bin

qgis --project "path to .qgz project file" --code "path to .py python code file"

The gqis bit in the second line needs to match whatever .bat file is run to open QGIS. for some users this was qgis-ltr. This launches qgis and opens a saved project, then runs the python script.

And my python script needed to start with the following to execute properly:

from qgis.core import *
import qgis.utils
from qgis.utils import iface