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 trialBrendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsImportError: numpy.core.multiarray failed to import
Code:
from s4v3 import *
import matplotlib.pyplot as plt
def create_line_chart(data_sample, title, exported_figure_filename):
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
prices = (sorted(map(float, data_sample)))
x_axis_ticks = list(range(len(data_sample)))
ax.plot(x_axis_ticks, prices, linewidth=2)
ax.set_title(title)
ax.set_xlim([0, len(data_sample)])
ax.set_xlabel('Tie Price ($)')
ax.set_ylabel('Number of Ties')
fig.savefig(exported_figure_filename)
create_line_chart([x[2] for x in gucci_ties[1:]], "Distribution of Prices for Gucci Ties", "_charts/s5-line-gucci.png")
Error message in console:
RuntimeError: module compiled against API version a but this version of num
py is 9
Traceback (most recent call last):
File "s5v1.py", line 2, in <module>
import matplotlib.pyplot as plt
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/matplot
lib/pyplot.py", line 27, in <module>
import matplotlib.colorbar
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/matplot
lib/colorbar.py", line 32, in <module>
import matplotlib.artist as martist
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/matplot
lib/artist.py", line 12, in <module>
from .transforms import Bbox, IdentityTransform, TransformedBbox, \
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/matplot
lib/transforms.py", line 39, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlappin
g_bbox,
ImportError: numpy.core.multiarray failed to import
Seems like maybe I need to install an updated version of something in workspaces?
2 Answers
Avery Uslaner
15,099 PointsUpdating numpy in Workspaces worked for me, it just took a while (~10 minutes).
pip install --upgrade numpy
Output:
100% |████████████████████████████████| 4.7MB 66kB/s
Installing collected packages: numpy
Running setup.py install for numpy
Successfully installed numpy-1.9.1
You are using pip version 7.1.2, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
pyenv: cannot rehash: /usr/local/pyenv/shims isn't writable
Code successfully ran after this. I'm just hoping the install persists after I close Workspaces :X
Hudson Cavanagh
1,695 PointsI am having a similar issue, and am frustrated by the lack of support by the Treehouse community on this issue. It means all the lessons (certainly bar charts, tables, or anything else related to numpy) hereafter are not going to work. Workspaces is one of the things that sets treehouse apart (I can study on my chromebook on the go!) so I will move on to use an alternative resources if no solutions are found to this issue!
Robert Farrimond
2,654 PointsRobert Farrimond
2,654 PointsI'm getting the same error, but if I download the workspace and run on my local environment (Python 3.5.1 |Anaconda 2.4.1 (x86_64)) everything works as expected.
I tried running "pip install -U numpy " in workspaces to see if this would fix the problem, but the installer would freeze and not finish the installation...