Determine QGIS Python Executable in Windows
Handy information if you are running scripts from the cmd...
Thank you for reading Back Office Dispatch!
If someone awesome shared this newsletter with you and you are not yet subscribed, please use the button below and join:
I have recently been writing several QGIS Python scripts for small one-off tasks. Most times, I just want to execute the script(s) and leverage QGIS built-in libraries and Python functionality, but not necessarily run the code from the QGIS Python console (although that is useful too).
In other words, headless.
QGIS ships with its own Python environment.
To locate the executable’s location, you can use the QGIS Python console like this:
import sys
print(sys.executable)In Windows, you’ll get something like:C:\Program Files\QGIS x.xx\bin\python-qgis.bat
Then, in the cmd, you can run a script like:
“C:\Program Files\QGIS x.xx\bin\python-qgis.bat” my_python_script.py
Your time and attention are valuable, and I’m grateful you choose to spend a little of it here….
Thank you for reading Back Office Dispatch.
Josh Otwell
P.S. If you’re facing a data problem similar to what I talk about here, you’re always welcome to reply and tell me what you’re working through.
Back Office Dispatch is a reader-supported publication. You can support this newsletter and keep it free for readers by donating a virtual coffee today!

