Environment variables#
- MPLBACKEND#
This optional variable can be set to choose the Matplotlib backend. SeeWhat is a backend?.
- MPLCONFIGDIR#
This is the directory used to store user customizations toMatplotlib, as well as some caches to improve performance. If
MPLCONFIGDIR
is not defined,HOME/.config/matplotlib
andHOME/.cache/matplotlib
are used on Linux, andHOME/.matplotlib
on other platforms, if they arewritable. Otherwise, the Python standard library'stempfile.gettempdir
isused to find a base directory in which thematplotlib
subdirectory iscreated.
- PATH#
The list of directories searched to find executable programs.
- PYTHONPATH#
The list of directories that are added to Python's standard search list whenimporting packages and modules.
- QT_API#
The Python Qt wrapper to prefer when using Qt-based backends. Seetheentry in the usage guide for more information.
Setting environment variables in Linux and macOS#
To list the current value ofPYTHONPATH
, which may be empty, try:
echo $PYTHONPATH
The procedure for setting environment variables in depends on what your defaultshell is. Common shells includebash andcsh. Youshould be able to determine which by running at the command prompt:
echo $SHELL
To create a new environment variable:
exportPYTHONPATH=~/Python# bash/kshsetenvPYTHONPATH~/Python# csh/tcsh
To prepend to an existing environment variable:
export PATH=~/bin:${PATH} # bash/kshsetenv PATH ~/bin:${PATH} # csh/tcsh
The search order may be important to you, do you want~/bin
to besearched first or last? To append to an existing environment variable:
export PATH=${PATH}:~/bin # bash/kshsetenv PATH ${PATH}:~/bin # csh/tcsh
To make your changes available in the future, add the commands to your~/.bashrc
or~/.cshrc
file.
Setting environment variables in Windows#
Open theControl Panel (Start ‣ Control Panel),start theSystem program. Click theAdvanced taband select theEnvironment Variables button. You can edit or add totheUser Variables.