Wednesday, 22 August 2012

Installing Matplotlib on Python3

Having recently tried to install matplotlib in a virtual environment for Python 3, I encountered some problems and decided to document the process I had to take to make sure it works:

In retrospective it actually was really easy and can be achieved with the following few steps [1]:

sudo apt-get install python3-tk tk tk-dev
pip install numpy
pip install git+

This will install the necessary packages for matplotlib:

  • numpy for fast mathematical computations.
  • tk for displaying the generated plots.

After these steps the following small program should display a very simple linear graph:

import matplotlib
import matplotlib.pyplot as plt
plt.ylabel('some numbers')

[1]Assuming you have already installed pip and are running Ubuntu or Linux Mint.