Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Data Science Basics Charts and Tables Bar Charts

'alloc: invalid block:' error when generating bar chart with matplotlib

After downloading the files from Workspaces and running s5v2.py on my local Windows 7 machine, I got the following crazy, non-descriptive error:

alloc: invalid block: 040F4158: 80 4

After quite a bit of research I found that I could get it to work if I changed the 'backend' that matplotlib was using from TkAgg to Qt4Agg.

To do that I created a matplotlibrc file in the .matplotlib directory in my home/user directory, and added/changed the following line:

backend      : Qt4Agg

Here is some matplotlib documentation that explains what is going on:

Hope that helps anyone else having a similar problem!

1 Answer

I had a very similar problem with my build on Windows 10. I should add that I was working through this lesson locally and not in workspaces.

I followed the instructions in this post but ultimately ended up with an error "ImportError: No module named 'PySide'.

I corrected that error by doing pip install pyside from the command prompt. The build works perfectly and the graphs look fantastic. Thinking a little more about the initial error it may have been a bad install on my end on whatever module the original code was using.

I was also using Windows. I think the setup will just be a bit different for each operating system, which isn't ideal when coding, but sometimes unavoidable.