This content originally appeared on DEV Community and was authored by Ronit Jadhav
Developing QGIS plugins in Python is much easier when you work inside a stable and isolated environment. Without it, package conflicts and version mismatches can quickly become frustrating.
This blog explains how to create a clean, reproducible QGIS plugin development environment using Conda and configure it for use in Visual Studio Code (VS Code).
Step 1: Install Conda
Conda is a cross-platform environment and package manager that helps you manage dependencies and isolate projects.
There are several versions available:
- Anaconda – Includes many scientific libraries out of the box but is large and slower to update.
- Miniconda – A lightweight installer that gives you full control over what gets installed.
-
Miniforge – A community version that defaults to the
conda-forgerepository, where QGIS packages are maintained. -
Mambaforge – The same as Miniforge but uses
mamba, a faster alternative toconda.
Recommendation: Use Miniforge or Mambaforge for a lightweight and modern setup.
Download the installer for your operating system and complete the installation using the default options.
Step 2: Create an Isolated QGIS Environment
To avoid conflicts with other Python setups, create a separate Conda environment dedicated to QGIS plugin development.
Open your terminal (or the Miniconda Prompt on Windows) and run:
conda create -n qgis_plugin_dev qgis -c conda-forge
To install a specific QGIS version:
conda create -n qgis_plugin_dev qgis=3.44.4 -c conda-forge
To specify both QGIS and Python versions:
conda create -n qgis_plugin_dev qgis=3.44.4 python=3.10 -c conda-forge
If you’re using Mambaforge, simply replace conda with mamba:
mamba create -n qgis_plugin_dev qgis=3.44.4 python=3.10
Windows users: After creating the environment, close and reopen the terminal to ensure the environment variables are properly updated.
Step 3: Install and Set Up VS Code
Installation
- Download the correct version for your operating system.
- On Windows, enable “Add to PATH” during installation so you can open VS Code directly from the command line.
- Launch VS Code once to finish setup.
Add Python Support
In VS Code, open the Extensions panel (Ctrl+Shift+X) and install the Python extension by Microsoft (ms-python).
After installing the extension, restart VS Code.
Step 4: Activate the Environment and Start Coding
Once everything is installed, you can begin your QGIS plugin development workflow.
Open your terminal.
Activate the new environment:
conda activate qgis_plugin_dev
- Move to your project directory:
cd path/to/your/plugin
- Launch VS Code from that directory:
code .
VS Code should automatically detect the qgis_plugin_dev environment and use it as the active Python interpreter.
Verify the Setup
Create a test file named check_pyqgis.py and add the following code:
from qgis.core import QgsApplication
print("QGIS Python environment is ready!")
If you see no import errors and autocompletion works for qgis.core, your setup is complete.
Step 5: Manage and Maintain the Environment
You can export your environment setup to share or reproduce it later:
conda env export > environment.yml
To rebuild it elsewhere:
conda env create -f environment.yml
To keep everything up to date:
conda update -n qgis_plugin_dev --all
Step 6: Begin QGIS Plugin Development
Your environment is now ready for plugin development. You can use it to:
- Write and test standalone PyQGIS scripts
- Develop and debug QGIS plugins using VS Code
- Experiment with spatial data processing in a clean environment
This setup keeps your plugin projects isolated from the main QGIS installation, ensuring consistent results across systems.
This content originally appeared on DEV Community and was authored by Ronit Jadhav