![pylab download error pylab download error](https://waterprogramming.files.wordpress.com/2016/04/slide1.png)
![pylab download error pylab download error](https://www.tutorialspoint.com/matplotlib/images/multiple_plot_commands.jpg)
Pylab download error code#
However, when I go over to my Ubuntu 14.04 machine and execute the exact same code all I see are my images: Figure 3: I have executed the exact same code on my Ubuntu system in the plotting virtual environment. When I execute the code on my OSX machine in the plotting virtual environment, the histogram is computed and both the grayscale image and histogram are displayed to my screen: Figure 2: Using OSX, I can successfully plot and display my grayscale histogram using matplotlib. To execute our script, all we need to do is fire up and shell and issue the following command: $ python grayscale_histogram.py Finally, Lines 14-22 plot the histogram using matplotlib. From there the cv2.calcHist function is used to compute a histogram over the grayscale pixel intensities. We then load our image and convert it to grayscale ( Lines 4-9). Gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # load the image, convert it to grayscale, and show it I’ll throw all this code into a file named grayscale_histogram.py : # import the necessary packages Now, let’s write a few lines of code to load the image, convert it to grayscale, compute a histogram over the grayscale image, and finally display it to our screen. Now that we’re in the plotting environment, let’s install numpy, scipy, and matplotlib : $ pip install numpyĪwesome - all of our Python dependencies are installed. Since we are using matplotlib, let’s create a new virtual environment called plotting : $ mkvirtualenv plotting And our goal is to take the following image (left) and compute a grayscale pixel intensity histogram for it using matplotlib (right):įigure 1: Our end goal is to utilize matplotlib to display a grayscale pixel intensity for the image on the left.We’re (optionally) utilizing Python virtual environments via virtualenv and virtualenvwrapper.We’re using a Debian based operating system such as Ubuntu or Raspbian.Matplotlib is a heavily used package in the Python scientific community and I hope that this article helps other readers resolve this strange and hard to pinpoint issue.
![pylab download error pylab download error](https://pythonprogramming.net/static/images/matplotlib/loading-data-from-file-matplotlib.png)
While this post is not exactly related to computer vision or OpenCV, I still want to share my experience and solution with other PyImageSearch readers.
Pylab download error trial#
Luckily, after a lot of trial and error (and spending an entire day trying to come up with a solution), I have been able to resolve the problem and get matplotlib figures to show up and display on my screen on both the Ubuntu and Raspbian operating systems (and when using Python virtual environments). The issue actually stems from the matplotlib backend not being properly set, or from a missing dependency when compiling and installing matplotlib. This issue is only further compounded when utilizing virtual environments via the virtualenv and virtualenvwrapper packages. This is actually a common problem I’ve ran into over the past few months, especially when working with Debian based operating systems such as Ubuntu and Raspbian. I coded up a quick Python script using matplotlib, executed the script, only to not have the figure displayed to my screen. Over the weekend I was playing around with deep learning on my Ubuntu system and went to plot the accuracy scores of my classifier. I think a better title for this blog post might be: How I lost a day of productivity to Ubuntu, virtual environments, matplotlib, and rendering backends. Click here to download the source code to this post