Gradle Version Kotlin Version

Python Gradle Plugin

Now, all what is required to run python scripts is Java.

This Gradle Plugin uses Miniforge to run executables (python, pip, conda etc.) from virtual env.

Python project configuration can be fully automated by Gradle tasks.


  • Java JDK or JRE version 8 or higher


Running python scripts or projects by executing single tasks which will download and install Python virtual environment.

Additional Python configuration (pip/conda packages installation etc.) can be done by defining Gradle tasks in build.gradle.kts file.


Steps to run python script from Gradle

  1. Apply a plugin to a project as described on gradle portal.

  2. Configure a plugin by specifying desired python version in build script:

    pythonPlugin {

    Possible properties in plugin extension are:

    • pythonVersion -> Python environment version, default 3.10.4
    • miniforgeVersion -> Miniforge3 version, default latest
  3. Define a task to run desired python script, for example to run script in main dir add the following task configuration to build script:

    tasks {
        register<VenvTask>("runQuickSort") {
                workingDir = projectDir.resolve("main")
                args = listOf("")
  4. Run python script from gradle:

    # Linux
    ./gradlew runQuickSort
    # Windows
    gradlew.bat runQuickSort
  5. Enjoy ? Quick Sort Python Script run

Additional examples alongside with sample PipTasks configurations can be found in examples module in this project.

Intellij setup

  • To have autocomplete and modules properly recognized in Intellij Idea simply point python executable as described in:
  • To have properly recognized imported source modules in tests, right click on sources directory (for example main) -> Mark Direcotry as -> as Sources root.

Python exec locations (* is a configured python version)

Linux – .gradle/python/pythonVenvs/virtualenv-*/bin/python

Windows – .gradle/python/pythonVenvs/virtualenv-*/Scripts/python.exe



This project is heavily inspired and is built on


View Github