> For the complete documentation index, see [llms.txt](https://docs.kivy.fun/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kivy.fun/programming-guide/environment.md).

# Controlling the Environment

Many environment variables are available to control the initialization and behavior of Kivy.

For example, in order to restrict text rendering to the PIL implementation:

```
$ KIVY_TEXT=pil python main.py
```

Environment variables should be set before importing kivy:

```
import os
os.environ['KIVY_TEXT'] = 'pil'
import kivy
```

## Path control

1.0.7

You can control the default directories where config files, modules and kivy data are located.

KIVY\_DATA\_DIR\
Location of the Kivy data, defaults to \<kivy path>/data

KIVY\_MODULES\_DIR\
Location of the Kivy modules, defaults to \<kivy path>/modules

KIVY\_HOME\
Location of the Kivy home. This directory is used for local configuration, and must be in a writable location.

Defaults to:

* Desktop: \<user home>/.kivy
* Android: \<android app path>/.kivy
* iOS: \<user home>/Documents/.kivy

1.9.0

KIVY\_SDL2\_PATH\
If set, the SDL2 libraries and headers from this path are used when compiling kivy instead of the ones installed system-wide. To use the same libraries while running a kivy app, this path must be added at the start of the PATH environment variable.

1.9.0

Warning

This path is required for the compilation of Kivy. It is not required for program execution.

## Configuration

KIVY\_USE\_DEFAULTCONFIG\
If this name is found in environ, Kivy will not read the user config file.

KIVY\_NO\_CONFIG\
If set, no configuration file will be read or written to. This also applies to the user configuration directory.

KIVY\_NO\_FILELOG\
If set, logs will be not print to a file

KIVY\_NO\_CONSOLELOG\
If set, logs will be not print to the console

KIVY\_NO\_ARGS\
If set, the argument passed in command line will not be parsed and used by Kivy. Ie, you can safely make a script or an app with your own arguments without requiring the -- delimiter:

```
import os
os.environ["KIVY_NO_ARGS"] = "1"
import kivy
```

1.9.0

## Restrict core to specific implementation

`kivy.core` try to select the best implementation available for your platform. For testing or custom installation, you might want to restrict the selector to a specific implementation.

KIVY\_WINDOW\
Implementation to use for creating the Window

Values: sdl2, pygame, x11, egl\_rpi

KIVY\_TEXT\
Implementation to use for rendering text

Values: sdl2, pil, pygame, sdlttf

KIVY\_VIDEO\
Implementation to use for rendering video

Values: gstplayer, ffpyplayer, ffmpeg, null

KIVY\_AUDIO\
Implementation to use for playing audio

Values: sdl2, gstplayer, ffpyplayer, pygame, avplayer

KIVY\_IMAGE\
Implementation to use for reading image

Values: sdl2, pil, pygame, imageio, tex, dds, gif

KIVY\_CAMERA\
Implementation to use for reading camera

Values: avfoundation, android, opencv

KIVY\_SPELLING\
Implementation to use for spelling

Values: enchant, osxappkit

KIVY\_CLIPBOARD\
Implementation to use for clipboard management

Values: sdl2, pygame, dummy, android

## Metrics

KIVY\_DPI\
If set, the value will be used for `Metrics.dpi`.

1.4.0

KIVY\_METRICS\_DENSITY\
If set, the value will be used for `Metrics.density`.

1.5.0

KIVY\_METRICS\_FONTSCALE

> If set, the value will be used for `Metrics.fontscale`.
>
> 1.5.0

## Graphics

KIVY\_GL\_BACKEND\
The OpenGL backend to use. See `~kivy.graphics.cgl`.

KIVY\_GL\_DEBUG\
Whether to log OpenGL calls. See `~kivy.graphics.cgl`.

KIVY\_GRAPHICS\
Whether to use OpenGL ES2. See `~kivy.graphics.cgl`.

KIVY\_GLES\_LIMITS\
Whether the GLES2 restrictions are enforced (the default, or if set to 1). If set to false, Kivy will not be truly GLES2 compatible.

Following is a list of the potential incompatibilities that result when set to true.

|              |                                                                                                                                                                                                                                                                                                                        |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Mesh indices | If true, the number of indices in a mesh is limited to 65535                                                                                                                                                                                                                                                           |
| Texture blit | When blitting to a texture, the data (color and buffer) format must be the same format as the one used at the texture creation. On desktop, the conversion of different color is correctly handled by the driver, while on Android, most of devices fail to do it. Ref: <https://github.com/kivytech/kivy/issues/1600> |

> 1.8.1

KIVY\_BCM\_DISPMANX\_ID\
Change the default Raspberry Pi display to use. The list of available value is accessible in vc\_dispmanx\_types.h. Default value is 0:

* 0: DISPMANX\_ID\_MAIN\_LCD
* 1: DISPMANX\_ID\_AUX\_LCD
* 2: DISPMANX\_ID\_HDMI
* 3: DISPMANX\_ID\_SDTV
* 4: DISPMANX\_ID\_FORCE\_LCD
* 5: DISPMANX\_ID\_FORCE\_TV
* 6: DISPMANX\_ID\_FORCE\_OTHER

KIVY\_BCM\_DISPMANX\_LAYER\
Change the default Raspberry Pi dispmanx layer. Default value is 0.

1.10.1


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.kivy.fun/programming-guide/environment.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
