How to Install QGIS Python Bindings on Windows
The fastest and officially supported way to install QGIS Python bindings on Windows is the OSGeo4W Network Installer. It resolves the compiled C++ dependencies, registers the environment variables PyQGIS needs, and links qgis.core and qgis.gui to a managed Python runtime. Do not run pip install pyqgis — the PyPI package is a documentation stub with none of the Windows binaries the real bindings require.
This is the Windows companion to the interactive workflow covered in the parent QGIS Python Console Basics guide. Inside QGIS the console already injects the correct PYTHONPATH for you; the goal here is to make the same qgis modules importable from an external interpreter so you can run scripts, IDEs, and automation outside the desktop. If you only want to script from within QGIS, you already have the bindings and can skip to the console guide.
Prerequisites
Confirm each of these before installing — most "it won't import" reports on Windows trace back to a mismatch in this list rather than a broken install:
- OS: Windows 10/11 64-bit only (32-bit was deprecated in QGIS 3.20).
- QGIS version: 3.44 LTR (recommended) or 4.0+ current.
- Python version: whatever ships with your QGIS — 3.12 for QGIS 3.34 and later (including 3.44 LTR); older releases such as 3.28 LTR bundled 3.9. You cannot substitute a separately installed Python.
- Architecture: strictly 64-bit throughout. Mixing a 32-bit Python with 64-bit QGIS DLLs raises
ImportErroron the firstimport qgis.core. - Permissions: administrator rights are needed only when the installer writes machine-level
PATH/PYTHONPATHentries. A per-session launcher works without elevation. - Environment conflicts: a standalone Anaconda/Miniconda base environment on the
PATHfrequently shadows the QGIS libraries. Keep conda deactivated, or isolate work in a dedicated environment as described in Virtual Environments for GIS.
Method 1: OSGeo4W Network Installer (recommended)
The OSGeo4W installer is the path that requires no manual path surgery — it wires up the environment for you.
- Download the OSGeo4W Network Installer (64-bit) from the official QGIS download page.
- Run it, choose
Install from Internet, and accept the default root (C:\OSGeo4W). Avoid spaces or special characters anywhere in the install path — they break several downstream scripts. - In the package selection screen, expand
Desktopand checkqgis-ltr(recommended) orqgis. - Expand
Libs→Pythonand verifypython3-qgisandpython3-qgis-commonare selected. Dependencies such asgdal-pythonandnumpyauto-select. - Complete the install. OSGeo4W registers
QGIS_PREFIX_PATHandPYTHONPATHand prepends the QGISbindirectories to yourPATH.
Verify the bindings
Launch the QGIS-managed Python shell so system Python cannot interfere:
C:\OSGeo4W\bin\python-qgis-ltr.bat
Then run this headless verification script. It initializes a full standalone QgsApplication — the same bootstrap every off-desktop script uses — and creates a throwaway memory layer to prove the data providers loaded:
import qgis.core
from qgis.core import QgsApplication
print(f"PyQGIS loaded: {qgis.core.Qgis.QGIS_VERSION}")
# Match your installation type: qgis-ltr or qgis
QgsApplication.setPrefixPath("C:/OSGeo4W/apps/qgis-ltr", True)
qgs = QgsApplication([], False)
qgs.initQgis()
layer = qgis.core.QgsVectorLayer("Point", "temp", "memory")
print(f"Test layer valid: {layer.isValid()}")
qgs.exitQgis()
If both lines print and the layer reports valid, module resolution and the GDAL/OGR providers are working. From here you can point an IDE at the same interpreter — see setting up PyCharm for QGIS development for the interpreter and environment-variable configuration.
Method 2: Standalone Installer (manual configuration)
If corporate firewalls block the OSGeo4W package repository, use the official QGIS Windows Standalone Installer instead. It does not auto-register Python paths, so you supply them yourself through a launcher.
- Install the standalone package (default:
C:\Program Files\QGIS 3.44). - Create a session launcher,
run_pyqgis.bat:
@echo off
set "QGIS_ROOT=C:\Program Files\QGIS 3.44"
set "PATH=%QGIS_ROOT%\bin;%QGIS_ROOT%\apps\qgis\bin;%PATH%"
set "PYTHONPATH=%QGIS_ROOT%\apps\qgis\python;%QGIS_ROOT%\apps\qgis\python\plugins;%PYTHONPATH%"
set "QGIS_PREFIX_PATH=%QGIS_ROOT%\apps\qgis"
set "PYTHONHOME=%QGIS_ROOT%\apps\Python312"
"%QGIS_ROOT%\bin\python3.exe"
- Double-click the batch file. It opens a terminal with PyQGIS importable for that session only, leaving machine-wide settings untouched. If your build ships a different Python, change
Python312to match the folder underapps\, and swapqgisforqgis-ltrin the paths if you installed the LTR variant. Run the same verification script above to confirm.
What the two installers actually give you
The choice between them is not about ease of installation but about whether you will ever need to add a package or run a script outside the application.
The environment variables that matter
Four variables have to be right before the bindings will import, and the OSGeo4W shell sets all four for you — which is precisely why it is the recommended route.
QGIS-version compatibility notes
The bindings are compiled against the exact Python, GDAL, PROJ, and Qt versions bundled with each QGIS release, so version alignment is not optional:
- QGIS 3.34 LTR / 3.44 LTR: Python 3.12, Qt 5. The examples on this page are pinned here. The launcher name is
python-qgis-ltr.batand the prefix path ends inapps/qgis-ltr. - QGIS 4.0+: Qt 6 and a newer Python; the
qgis-ltrsuffix becomesqgis, so usepython-qgis.batand theapps/qgisprefix. - QGIS 3.28 LTR and older: shipped Python 3.9. Methods that appeared in later APIs will raise
AttributeErrorhere.
Because method names and enum locations drift between releases, cross-check any snippet against your installed version using the QGIS Python version compatibility guide before assuming it will run. Always drive external scripts with the interpreter that matches the QGIS build whose libraries they import — never a system or conda Python.
Troubleshooting
DLL load failed while importing qgis.core— the Visual C++ Redistributable (2015–2022) is missing, or thePATHresolves a conflicting DLL first. Install the latest VC++ runtime and make sure the QGISbindirectories precede any system Python paths. Launching throughpython-qgis-ltr.batsidesteps most ordering issues because it sets the environment for you.ModuleNotFoundError: No module named 'qgis'— the interpreter cannot seePYTHONPATH, usually because an IDE points at a plain system Python. Point it atC:\OSGeo4W\bin\python-qgis-ltr.bat, or work through the deeper diagnosis in fixing PyQGIS module import errors.- Proxy / network timeouts during install — set
http_proxyandhttps_proxybefore launching OSGeo4W, or download the.msipackages manually and chooseInstall from Local Directory. - Third-party packages invisible to PyQGIS — install libraries such as
pandasorrequeststhrough the bundled shell (python-qgis-ltr.bat -m pip install <package>) so they land in the QGIS interpreter's site-packages and match its ABI. Installing into a system or conda Python leaves them unimportable from PyQGIS.
Conclusion
On Windows, reliable PyQGIS bindings come from installing QGIS itself — through OSGeo4W when you can reach its repository, or the standalone installer with a run_pyqgis.bat launcher when you cannot — and never from pip install pyqgis. Once the headless verification script prints a version and a valid layer, the same interpreter is ready to drive IDEs, scheduled jobs, and standalone tools. From here, move into the interactive QGIS Python Console Basics to explore the API live, then formalize your setup with Virtual Environments for GIS for reproducible builds.
Frequently Asked Questions
Why can't I just run pip install pyqgis to get the bindings on Windows?
The PyPI pyqgis package is a documentation stub with no compiled binaries, so it cannot satisfy the C++ dependencies PyQGIS requires. The bindings are tightly coupled to QGIS's bundled GDAL, PROJ, and Qt builds, which must be installed together. Use the OSGeo4W Network Installer or the standalone installer so the binaries and their versions match exactly.
Which Python version do the QGIS Windows bindings require?
QGIS 3.34 and later, including 3.44 LTR, bundle Python 3.12, while older releases such as 3.28 LTR shipped Python 3.9. You must use the interpreter that ships with your QGIS install rather than a separately installed Python, because the compiled modules are built against that specific version. Mixing versions produces ImportError or ABI mismatch failures.
How do I install third-party packages like pandas into the QGIS Python environment?
Run pip through the bundled shell, for example python-qgis-ltr.bat -m pip install pandas, so packages land in the QGIS interpreter's site-packages. Installing into a system or conda Python instead leaves them invisible to PyQGIS and risks ABI conflicts. Always confirm the install used the OSGeo4W Python before importing the package in a script.
What causes DLL load failed while importing qgis.core on Windows?
This usually means the Visual C++ Redistributable (2015–2022) is missing or the system PATH resolves a conflicting DLL before the QGIS one. Install the latest VC++ runtime and ensure the QGIS bin directories appear ahead of any system Python paths. Launching through python-qgis-ltr.bat sidesteps most ordering problems because it sets the environment for you.
Do I need administrator rights to install the bindings?
Administrator privileges are needed when the installer registers system-level PATH and PYTHONPATH entries. If you cannot elevate, you can still use the bundled python-qgis-ltr.bat launcher or a per-session batch file that sets the variables for that shell only. This keeps PyQGIS working without modifying machine-wide environment settings.
Related
- Up: QGIS Python Console Basics — the parent guide to the interactive console the bindings power.
- Running Python Scripts Outside QGIS Desktop — the initialization pattern for the interpreter you just configured.
- Setting Up PyCharm for QGIS Development — point a full IDE at the OSGeo4W interpreter.
- Fixing PyQGIS Module Import Errors — diagnose
ModuleNotFoundErrorand DLL failures in depth. - Virtual Environments for QGIS and PyQGIS — isolate dependencies for reproducible builds.
- Up one level: PyQGIS Fundamentals & Environment Setup — the full environment reference.