DEV Community

Cover image for Setting Up a QGIS Plugin Development Environment with Conda and VS Code
Ronit Jadhav
Ronit Jadhav

Posted on

Setting Up a QGIS Plugin Development Environment with Conda and VS Code

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-forge repository, where QGIS packages are maintained.
  • Mambaforge – The same as Miniforge but uses mamba, a faster alternative to conda.

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
Enter fullscreen mode Exit fullscreen mode

To install a specific QGIS version:

conda create -n qgis_plugin_dev qgis=3.44.4 -c conda-forge
Enter fullscreen mode Exit fullscreen mode

To specify both QGIS and Python versions:

conda create -n qgis_plugin_dev qgis=3.44.4 python=3.10 -c conda-forge
Enter fullscreen mode Exit fullscreen mode

If you’re using Mambaforge, simply replace conda with mamba:

mamba create -n qgis_plugin_dev qgis=3.44.4 python=3.10
Enter fullscreen mode Exit fullscreen mode

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

  1. Download the correct version for your operating system.
  2. On Windows, enable “Add to PATH” during installation so you can open VS Code directly from the command line.
  3. 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.

  1. Open your terminal.

  2. Activate the new environment:

   conda activate qgis_plugin_dev
Enter fullscreen mode Exit fullscreen mode
  1. Move to your project directory:
   cd path/to/your/plugin
Enter fullscreen mode Exit fullscreen mode
  1. Launch VS Code from that directory:
   code .
Enter fullscreen mode Exit fullscreen mode

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!")
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

To rebuild it elsewhere:

conda env create -f environment.yml
Enter fullscreen mode Exit fullscreen mode

To keep everything up to date:

conda update -n qgis_plugin_dev --all
Enter fullscreen mode Exit fullscreen mode

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.

Top comments (0)