Can't install Matplotlib on Python 3.10 after its release (2021-10-05)

Solution 1:

As others have stated, Python 3.10 is not currently compatible with Matplotlib. You need to install and use Python 3.9 until it is supported. Until then you have a few options:

Windows

You can use the Python Launcher for Windows (py.exe) script to choose which Python version to run like so:

py.exe script help: py -h

List all installed versions py -0

Use a specified version py -3.9

e.g. 1 Create a virtual environment using python 3.9 py -3.9 venv .venv

e.g. 2 install matplotlib with pip using python 3.9 py -3.9 -m pip install matplotlib

Linux

On Linux you can run whatever Python version you like like so:

python3.9

You can set up a local (your working directory and all sub-directories) virtual environment that will use your specified version like so:

python3.9 -m venv .venv

Which will set the version of python used to 3.9 while in the local directory, and allow you to type python instead of python3.9 each time you need it.

Another relevant and helpful post by Rotareti here.

Please note that I have not described how to activate and use Python Virtual Environments here in detail, for more information on using them read the python docs.

Reference this answer if you're interested in installing a matplotlib release candidate.