Cython: numpy.ufunc has the wrong size

I am trying to implement a plugin using Cython, but when I start CellProfiler I get an error message: “ValueError: numpy.ufunc has the wrong size, try recompiling”. What is wrong? Do I need to have exact the same numpy version as in CellProfiler? I am running CellProfiler 2.1.2 (rev e6ab085), but I get a similar error message also for 2.1.0. I have attached the files for a simplified version of my code.

Here is the full output when starting CellProfiler:
Could not load SimpleExample
Traceback (most recent call last):
File “cellprofiler\modules_init_.pyc”, line 303, in add_module
File “C:\Program Files/CellProfiler/plugins\”, line 1, in
File “numpy.pxd”, line 861, in init SimpleExampleFunctions (SimpleExampleFunct
ValueError: numpy.ufunc has the wrong size, try recompiling
could not load these modules: SimpleExample
Version: 2015-05-04T20:08:42 e6ab085 / 20150504200842 (105 KB)

Yup - has to be the same version of Numpy as CellProfiler. The numpy C header files have to have the same structure definitions. To find out the version, create a Python file in your plugins folder with the text:

import numpy
print "Numpy version = " + numpy.__version__

I think you only need to match the major and minor versions - Numpy 1.8.2 should be compatible with 1.8.1 for instance.

OK, thanks Lee.
When I run that I get numpy version 1.7.1 for CellProfiler. Is that correct?
In my current python version I have numpy 1.9.2.

I have a 64-bit Windows so I run the 64-bit CellProfiler, which means that I would need to use 64-bit Python, 64-bit numpy 1.7.1 and a 64-bit C++ compiler, right? I have not been able to find a 64-bit version of numpy 1.7.1. Could you guide me how to find that?
The numpy 1.7.1 files are no longer available from
I have also looked for, but these files are not available either.

Hi Petter,

Lee says that the easiest way is this: “Basically, he needs a clone of our dev environment.”. We have instructions here to do this: … er-install

There is one broken link though ( which I need to update manually right now, but I will try and do that shortly.


OK, the file is on the webserver now. See if that works for you.

OK, I will try that.
Thanks David!

Do I need the python27.dll? That link does not work either (

Hmm, not sure. Does it work without the dll?

And you likely have a copy already, probably in C:\Windows\System32.

Well, I uninstalled python to get a clean sheet before installing all the CellProfiler stuff. After reinstalling python it works fine. I can build my plugin using cython and start it from CellProfiler. So far so good. My next problem is about how to access the pixel data. You can see the code in the attached file above.
In I do the function call as follows:
pixel_data = image.pixel_data.copy()
thr = sef.simpleExample(pixel_data, pixel_data.shape[1], pixel_data.shape[0])

In SimpleExampleFunctions.pxy I have this definition:
def simpleExample(np.ndarray[dtype=np.float64_t, ndim=2, negative_indices=False, mode=‘c’] dataIn, int width, int height):

When running the pipeline in CellProfiler I get the following error message:
ValueError: Buffer dtype mismatch, expected ‘float64_t’ but got ‘float’

What is wrong?

It seems to work if I change to float32_t in the .pyx file. Is that the format I should use?