Getting an error on Check50 for Similarities, Pset6. When I run Check50 the log file states:

:( helpers.py compiles
No module named 'numpy' 

I'm using the numpy package for setting up the 2D matrix. My application works as it should be, there is no problem when compiling and running it and testing the similarities app manually. I have installed the numpy package by executing pip3 install numpy from the command-line.

At the top of the file I import numpy by this line (I use only the empty function):

from numpy import empty

Is there anybody who uses the numpy package as well, and knows what to do to pass check50?

PS: I read the related question by Elvin Pang. Since I couldn't use numpy I asked CS50 heads if I should install it and they advised to do so by pip3 install numpy after which my code worked.

1 Answer 1


You can't install modules on the server, but just creating an empty 2D array doesn't require a whole library. A simple list comprehension like

matrix = [[None] * width for y in range(height)]

would work.

I use two concepts here.

[None] * width will concatenate the list width times. Beware that this involves a shallow copy, so it would not work for height, as it would not include multiple rows, but the same row multiple times. None does not have any issues, as it is immutable. 0 might also be a good candidate for an initial value, whatever works best with your code.

[expression for x in range(height)] works like a for loop, evaluating the expression in each iteration, and creating a list from those. Could also do things like

matrix = [[x * y for x in range(width)] for y in range(height)]

to get a multiplication table, in case you ever need one.

So while numpy is surely great, and you might use it on the final project (which, as far as I understand, might be judged based mostly on the presentation video, without ever being run by the staff), it's probably not expected for the other problems. Or maybe it's not installed by mistake, but it's easy to work around that.

  • Thanks, will try this! Will update and upvote when I’m finished with the Pset6.
    – JJuice
    Dec 1, 2018 at 13:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .