Matplotlib problem with Virtualenv

less than 1 minute read

For my thesis I’m working with Python and the library for plotting graphs Matplotlib.

I wanted to use the useful Virtualenv for having all the libraries I’m using in one place and no having problems with versions and other stuff.

I installed everything and I tried to execute my main script. For my surprise, a new error appears telling me that I need to install Python framework for being able to use matplotlib with a virtualenv or Conda.

As always, a quick search lead me to Stackoverflow, where I found the solution to my problem, for my operating system, which is MacOS.

So the solution to the problem is the following, first is presupposed that you have installed matplotlib with pip:

  • There is a directory in your root that is called: ~/.matplotlib.
  • You have to create a new file ~/.matplotlib/matplotlibrcand then type in this new file the following: backend: TkAgg.

With this I’ve solved my problem. Thank you again Stackoverflow! :)

Paco