Empowering you to understand your world

How To Fix The Error ‘Package ‘python-matplotlib’ has no installation candidate’

If you’re trying to get started with machine learning and the command ‘sudo apt install python-matplotlib’ yields the following error:

Package python-matplotlib is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

It may be because your operating system no longer carries that version of the package, which is for Python 2, rather than the latest which is Python 3. Newer releases of Linux distributions have started excluding Python 2, and Python 3 is now the default.

To get around this problem, you can install python3-matplotlib instead, just ensure that the libraries and software you are running are compatible with Python 3. Sometimes libraries are under-maintained and will only run Python 2.7. If you do encounter a problem with libraries expecting the default Python installation to be 2.7, please avoid making Python 2.7 the default, as that is harmful (newer distributions like Ubuntu 22.04 depend on Python 3 as the default).

sudo apt install python3-matplotlib

Try the same with dnf in Fedora or whichever install command corresponds to your Linux distribution. It will install the correct version of ‘matplotlib’ for Python 3.

Leave a Reply

Subscribe to our newsletter
Get notified when new content is published