Установить matplotlib для python windows

Install an official release#

Matplotlib releases are available as wheel packages for macOS, Windows and
Linux on PyPI. Install it using
pip:

python -m pip install -U pip
python -m pip install -U matplotlib

If this command results in Matplotlib being compiled from source and
there’s trouble with the compilation, you can add --prefer-binary to
select the newest version of Matplotlib for which there is a
precompiled wheel for your OS and Python.

Note

The following backends work out of the box: Agg, ps, pdf, svg

Python is typically shipped with tk bindings which are used by
TkAgg.

For support of other GUI frameworks, LaTeX rendering, saving
animations and a larger selection of file formats, you can
install Optional dependencies.

Third-party distributions#

Various third-parties provide Matplotlib for their environments.

Conda packages#

Matplotlib is available both via the anaconda main channel

as well as via the conda-forge community channel

conda install -c conda-forge matplotlib

Python distributions#

Matplotlib is part of major Python distributions:

  • Anaconda

  • ActiveState ActivePython

  • WinPython

Linux package manager#

If you are using the Python version that comes with your Linux distribution,
you can install Matplotlib via your package manager, e.g.:

  • Debian / Ubuntu: sudo apt-get install python3-matplotlib

  • Fedora: sudo dnf install python3-matplotlib

  • Red Hat: sudo yum install python3-matplotlib

  • Arch: sudo pacman -S python-matplotlib

Install a nightly build#

Matplotlib makes nightly development build wheels available on the
scientific-python-nightly-wheels Anaconda Cloud organization.
These wheels can be installed with pip by specifying
scientific-python-nightly-wheels as the package index to query:

python -m pip install \
  --upgrade \
  --pre \
  --index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple \
  --extra-index-url https://pypi.org/simple \
  matplotlib

Install from source#

Installing for Development

If you would like to contribute to Matplotlib or otherwise need to
install the latest development code, please follow the instructions in
Setting up Matplotlib for development.

The following instructions are for installing from source for production use.
This is generally not recommended; please use prebuilt packages when possible.
Proceed with caution because these instructions may result in your
build producing unexpected behavior and/or causing local testing to fail.

Before trying to install Matplotlib, please install the Dependencies.

To build from a tarball, download the latest tar.gz release
file from the PyPI files page.

We provide a mplsetup.cfg file which you can use to customize the build
process. For example, which default backend to use, whether some of the
optional libraries that Matplotlib ships with are installed, and so on. This
file will be particularly useful to those packaging Matplotlib.

If you are building your own Matplotlib wheels (or sdists) on Windows, note
that any DLLs that you copy into the source tree will be packaged too.

Configure build and behavior defaults#

Aspects of the build and install process and some behaviorial defaults of the
library can be configured via Environment variables. Default plotting
appearance and behavior can be configured via the
rcParams file

Frequently asked questions#

Report a compilation problem#

See Get help.

Matplotlib compiled fine, but nothing shows up when I use it#

The first thing to try is a clean install and see if
that helps. If not, the best way to test your install is by running a script,
rather than working interactively from a python shell or an integrated
development environment such as IDLE which add additional
complexities. Open up a UNIX shell or a DOS command prompt and run, for
example:

python -c "from pylab import *; set_loglevel('debug'); plot(); show()"

This will give you additional information about which backends Matplotlib is
loading, version information, and more. At this point you might want to make
sure you understand Matplotlib’s configuration
process, governed by the matplotlibrc configuration file which contains
instructions within and the concept of the Matplotlib backend.

If you are still having trouble, see Get help.

How to completely remove Matplotlib#

Occasionally, problems with Matplotlib can be solved with a clean
installation of the package. In order to fully remove an installed Matplotlib:

  1. Delete the caches from your Matplotlib configuration directory.

  2. Delete any Matplotlib directories or eggs from your installation
    directory
    .

OSX Notes#

Which python for OSX?#

Apple ships OSX with its own Python, in /usr/bin/python, and its own copy
of Matplotlib. Unfortunately, the way Apple currently installs its own copies
of NumPy, Scipy and Matplotlib means that these packages are difficult to
upgrade (see system python packages). For that reason we strongly suggest
that you install a fresh version of Python and use that as the basis for
installing libraries such as NumPy and Matplotlib. One convenient way to
install Matplotlib with other useful Python software is to use the Anaconda
Python scientific software collection, which includes Python itself and a
wide range of libraries; if you need a library that is not available from the
collection, you can install it yourself using standard methods such as pip.
See the Anaconda web page for installation support.

Other options for a fresh Python install are the standard installer from
python.org, or installing
Python using a general OSX package management system such as homebrew or macports. Power users on
OSX will likely want one of homebrew or macports on their system to install
open source software packages, but it is perfectly possible to use these
systems with another source for your Python binary, such as Anaconda
or Python.org Python.

Installing OSX binary wheels#

If you are using Python from https://www.python.org, Homebrew, or Macports,
then you can use the standard pip installer to install Matplotlib binaries in
the form of wheels.

pip is installed by default with python.org and Homebrew Python, but needs to
be manually installed on Macports with

sudo port install py38-pip

Once pip is installed, you can install Matplotlib and all its dependencies with
from the Terminal.app command line:

python3 -m pip install matplotlib

You might also want to install IPython or the Jupyter notebook (python3 -m pip
install ipython notebook
).

Checking your installation#

The new version of Matplotlib should now be on your Python «path». Check this
at the Terminal.app command line:

python3 -c 'import matplotlib; print(matplotlib.__version__, matplotlib.__file__)'

You should see something like

3.6.0 /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/matplotlib/__init__.py

where 3.6.0 is the Matplotlib version you just installed, and the path
following depends on whether you are using Python.org Python, Homebrew or
Macports. If you see another version, or you get an error like

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named matplotlib

then check that the Python binary is the one you expected by running

If you get a result like /usr/bin/python..., then you are getting the
Python installed with OSX, which is probably not what you want. Try closing
and restarting Terminal.app before running the check again. If that doesn’t fix
the problem, depending on which Python you wanted to use, consider reinstalling
Python.org Python, or check your homebrew or macports setup. Remember that
the disk image installer only works for Python.org Python, and will not get
picked up by other Pythons. If all these fail, please let us know.

Troubleshooting#

Obtaining Matplotlib version#

To find out your Matplotlib version number, import it and print the
__version__ attribute:

>>> import matplotlib
>>> matplotlib.__version__
'0.98.0'

matplotlib install location#

You can find what directory Matplotlib is installed in by importing it
and printing the __file__ attribute:

>>> import matplotlib
>>> matplotlib.__file__
'/home/jdhunter/dev/lib64/python2.5/site-packages/matplotlib/__init__.pyc'

matplotlib configuration and cache directory locations#

Each user has a Matplotlib configuration directory which may contain a
matplotlibrc file. To
locate your matplotlib/ configuration directory, use
matplotlib.get_configdir():

>>> import matplotlib as mpl
>>> mpl.get_configdir()
'/home/darren/.config/matplotlib'

On Unix-like systems, this directory is generally located in your
HOME directory under the .config/ directory.

In addition, users have a cache directory. On Unix-like systems, this is
separate from the configuration directory by default. To locate your
.cache/ directory, use matplotlib.get_cachedir():

>>> import matplotlib as mpl
>>> mpl.get_cachedir()
'/home/darren/.cache/matplotlib'

On Windows, both the config directory and the cache directory are
the same and are in your Documents and Settings or Users
directory by default:

>>> import matplotlib as mpl
>>> mpl.get_configdir()
'C:\\Documents and Settings\\jdhunter\\.matplotlib'
>>> mpl.get_cachedir()
'C:\\Documents and Settings\\jdhunter\\.matplotlib'

If you would like to use a different configuration directory, you can
do so by specifying the location in your MPLCONFIGDIR
environment variable — see
Setting environment variables in Linux and macOS. Note that
MPLCONFIGDIR sets the location of both the configuration
directory and the cache directory.

Search code, repositories, users, issues, pull requests…

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Project description

PyPi
Conda
Downloads
NUMFocus

Discourse help forum
Gitter
GitHub issues
Contributing

GitHub actions status
Azure pipelines status
AppVeyor status
Codecov status

Matplotlib logotype

Matplotlib is a comprehensive library for creating static, animated, and
interactive visualizations in Python.

Check out our home page for more information.

image

Matplotlib produces publication-quality figures in a variety of hardcopy
formats and interactive environments across platforms. Matplotlib can be
used in Python scripts, Python/IPython shells, web application servers,
and various graphical user interface toolkits.

Install

See the install
documentation,
which is generated from /doc/users/installing/index.rst

Contribute

You’ve discovered a bug or something else you want to change — excellent!

You’ve worked out a way to fix it — even better!

You want to tell us about it — best of all!

Start at the contributing
guide!

Contact

Discourse is the discussion forum
for general questions and discussions and our recommended starting
point.

Our active mailing lists (which are mirrored on Discourse) are:

  • Users
    mailing list: matplotlib-users@python.org
  • Announcement
    mailing list: matplotlib-announce@python.org
  • Development
    mailing list: matplotlib-devel@python.org

Gitter is for coordinating
development and asking questions directly related to contributing to
matplotlib.

Citing Matplotlib

If Matplotlib contributes to a project that leads to publication, please
acknowledge this by citing Matplotlib.

A ready-made citation
entry is
available.

Download files

Download the file for your platform. If you’re not sure which to choose, learn more about installing packages.

Source Distribution

Built Distributions

In this Python tutorial, we will discuss How to install matplotlib python with all the required dependencies to use the package in the data visualization in python and we shall also cover the following topics:

  • How to install matplotlib python
  • How to install matplotlib python ubuntu
  • How to install matplotlib python windows
  • How to install matplotlib python mac
  • How to install matplotlib python conda
  • How to install matplotlib python pip
  • How to install matplotlib python venv
  • How to install matplotlib python3
  • How to install matplotlib python2

You can install matplotlib library to use it in python in all the three major operating systems commonly used:

  • Linux (Ubuntu, redhat, etc.,)
  • Windows
  • macOS

You can install matplotlib in any of these operating systems either by using the pip command (using the python package manager) to install the released wheel packages available, or by creating a separate virtual environment for matplotlib from other installations of the python and matplotlib, or by using another environment such as anaconda which provides conda as a package manager to install packages.

NOTE –

  • Wheel Package is a built-package format for python having the .whl file extension. It contains all the files related to an install package for python with its metadata.
  • Virtual Environment is just a named directory for development in python containing all the necessary dependencies and packages installed inside that directory.
  • Anaconda is a distribution of python that provides an environment to develop python projects based on scientific researches.

Read: modulenotfounderror: no module named ‘matplotlib’

How to install matplotlib python ubuntu

How to install matplotlib python using pip in Linux (Ubuntu)

You can install matplotlib for python in any of the Linux distributions including Ubuntu, by using the python package manager which provides the pip command to install any wheel package released for python. First, make sure that you have installed python and pip in your system. If you don’t have pip installed, first you have to install it, then install the matplotlib using pip. Execute the below commands in the terminal:

python -m pip install -U pip
python -m pip install -U matplotlib [--prefer-binary]

In the above commands,

  • The first command updates the pip python package manager.
  • In the second command, –prefer-binary is optional, if the command excluding the –prefer-binary option fails to install or update the matplotlib package. Then add this option, it selects the newest version according to the precompiled wheel for your operating system and python installed.

You can check if matplotlib is successfully installed on your system by executing the command below in the terminal:

import matplotlib
matplotlib.__version__

How to install matplotlib python Linux package manager

In Linux, python is pre-installed with the OS distribution, and if you are using that version, then you can install matplotlib by using Linux package manager, Different distributions have different package managers:

  • For Debian / Ubuntu you can use the following command:
sudo apt-get install python3-matplotlib
  • For Red Hat you can use the following command:
sudo yum install python3-matplotlib
  • For Fedora you can use the following command:
sudo dnf install python3-matplotlib
  • For Arch you can use the following command:
sudo pacman -S python-matplotlib

How to install matplotlib python venv in Linux

You can install matplotlib in a virtual development environment in Linux, by using Python’s virtual environment venv to create a virtual environment. The steps for doing it are given below:

  • Creating a virtual environment:
python -m venv <directory_path>

The above command creates a virtual environment (a dedicated directory) in the location <directory_path>.

  • Activate the environment created:
source <directory_path>/bin/activate

The above command activates the development environment. You have to activate the development environment in the shell first, whenever you start working on the matplotlib.

  • Retrieve the latest version of matplotlib from the git hosted at https://github.com/matplotlib/matplotlib.git. The below command retrieves the latest sources of matplotlib to the current working directory:
git clone https://github.com/matplotlib/matplotlib.git
  • Now, install matplotlib in the editable (develop) mode as the develop mode let python to import matplotlib from your development environment source directory, that is from the git source, which allows you to import the latest version of matplotlib without re-installing it after any change happens to the source. The below command lets you do it:
python -m pip install -ve

Now, you can import the matplotlib package and use it in your development environment.

Read: Slicing string in Python

How to install matplotlib python windows

How to install matplotlib python pip in Windows

You can install matplotlib for python in a Windows OS, by using the python package manager which provides the pip command to install any wheel package released for python.

First, make sure that you have installed python and pip in your system. If you don’t have pip installed, first you have to install it, then install the matplotlib using pip. Execute the below commands in the cmd:

python -m pip install -U pip        # Update the pip package manager
python -m pip install -U matplotlib [--prefer-binary]

The above command is the same as we have done in Linux distribution in the above topic.

You can check if matplotlib is successfully installed on your system by executing the command below in the cmd:

import matplotlib
matplotlib.__version__

How to install matplotlib python venv in Windows

You can create a virtual environment in python and configure it for the development of matplotlib in Windows by following the given steps:

  • Creating a virtual environment:
python -m venv <directory_path>

The above command creates a virtual environment (a dedicated directory) in the location <directory_path>.

  • Activate the environment created:
source <directory_path>/bin/activate.bat

# Note that, this command was different for Linux distribution

The above command activates the development environment. You have to activate the development environment in the shell first, whenever you start working on the matplotlib.

  • All the steps are same as done for the Linux distribution:
# Retrieve the latest version of matplotlib from the git source

git clone https://github.com/matplotlib/matplotlib.git


# Install matplotlib in the editable mode

python -m pip install -ve

The above commands are already discussed in the previous topic.

Read: Python NumPy Random

How to install matplotlib python mac

How to install matplotlib python pip in macOS

You can install matplotlib for python in a macOS, by using the python package manager which provides the pip command to install any wheel package released for python. First, make sure that you have installed python and pip in your system. If you don’t have pip installed, first you have to install it, then install the matplotlib using pip. Execute the below commands in the cmd:

python -m pip install -U pip        # Update the pip package manager
python -m pip install -U matplotlib [--prefer-binary]

The above command is also the same as we have done and discussed for the Linux distribution.

You can check if matplotlib is successfully installed on your system by executing the command below in the terminal:

import matplotlib
matplotlib.__version__

How to install matplotlib python venv in macOS

The steps to create a dedicated development environment for the matplotlib python in macOS are the same as we have done and discussed for the Linux distribution.

# You can see that all the steps are same, as done for the Linux

# Creating a development environment
python -m venv <directory_path>


# Activate the created environment
source <directory_path>/bin/activate


# Retrieve the latest version of matplotlib from the git source
git clone https://github.com/matplotlib/matplotlib.git


# Install matplotlib in the editable mode
python -m pip install -ve

Read: Python Tkinter OptionMenu

How to install matplotlib python conda

Matplotlib is also part of some major Python distributions like an anaconda. So, you can install matplotlib in this distribution of python which provides its environment for the matplotlib. Anaconda is available for all three major operating systems, Linux, Windows, macOS. You can use the package manager provided by anaconda that is conda to install the matplotlib. You must have installed anaconda in your system then you can execute the command below in the cmd /conda prompt/terminal:

conda install matplotlib

The above command will install the matplotlib in the anaconda development environment from the anaconda main channel.

You can install matplotlib from the anaconda community channel also by executing the command below.

conda install -c conda-forge matplotlib

How to install matplotlib python3

If you are using python3 then use pip3 in place of pip to install the matplotlib. All the installation process is same as given in above topics, just use pip3 instead.

How to install matplotlib python2

If you are using python2 then use pip to install the matplotlib. All the installation process is same as given in above topics.

You may also like reading the following articles.

  • How to install Django
  • What is Python Django
  • Python plot multiple lines
  • Matplotlib plot a line
  • What is matplotlib inline
  • Matplotlib subplot tutorial

In this Python tutorial, we have discussed How to install matplotlib python with all the required dependencies to use the package in the data visualization in python and we have also covered the following topics:

  • How to install matplotlib python
  • How to install matplotlib python ubuntu
  • How to install matplotlib python windows
  • How to install matplotlib python mac
  • How to install matplotlib python conda
  • How to install matplotlib python pip
  • How to install matplotlib python venv
  • How to install matplotlib python3
  • How to install matplotlib python2

Bijay - Python Expert

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.

Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack.

In this article, we will look into the various process of installing Matplotlib on Windows.

Pre-requisites:

The only thing that you need for installing Numpy on Windows are:

  • Python 
  • PIP or Conda (depending upon user preference)

Installing Matplotlib on Windows:

For Conda Users:

If you want the installation to be done through conda, you can use the below command:

conda install matplotlib

Type y for yes when prompted.

You will get a similar message once the installation is complete

installing Matplotlib using conda

Make sure you follow the best practices for installation using conda as:

  • Use an environment for installation rather than in the base environment using the below command:
conda create -n my-env
conda activate my-env

Note: If your preferred method of installation is conda-forge, use the below command:

conda config --env --add channels conda-forge

For PIP Users:

Users who prefer to use pip can use the below command to install Matplotlib:

pip install matplotlib

You will get a similar message once the installation is complete:

installing Matplotlib using PIP

Verifying Matplotlib Installation:

To verify if Matplotlib has been successfully installed in your system run the below code in a python IDE of your choice:

Python3

import matplotlib

matplotlib.__version__

If successfully installed you will get the following output.

Verifying Matplotlib installation

Last Updated :
09 Sep, 2021

Like Article

Save Article

  • Установить icloud на компьютер для windows 10
  • Установить microsoft office 2007 бесплатно для windows 10
  • Установить hyper v windows 10 powershell
  • Установить microsoft net framework для windows 7
  • Установить facebook на компьютер бесплатно для windows 7 на русском языке