Importing multiprocessing module in ironPython

I already asked directely into Steve Baer wordpress blog, before knowing the existance of such a community around mcNeel products.
I usually write my scripts throught the ironPython Grasshopper editor.
I’m having some trouble with the import of the multiprocessing module in my script.
This is the error:

line 16, in , “C:\Program Files\Rhinoceros 5 (64-bit)\Plug-ins\IronPython\Lib\”

After verifying that it works fine in the ironPython IDE, I didn’t solve the problem.
After some search i’ve found there are some troubles in translating Python module into ironPython module.
What am I doing wrong?


By IronPython IDE, are you referring to the editor in Rhino that you get when you run the “EditPythonScript” command?

Hi steve,
thanks for the quick response.
No, i don’t, i’m referring to an external shell, downloaded separately, that doesn’t interact with rhino.
Where i run the simple line

import multiprocessing

into the Pythonscript, it send me the same error.
It’s like it can’t import child module from the initializer.
Line 16 is a simple

from . import context

Rhino ships with and uses an older version of IronPython than what you get when you download the external shell. This may be the issue.

What is it that you are trying to do? There is probably a workaround

The version doc says it’s the 2.7.0 beta version, in fact.
I’m trying to handle a python script built into the grasshopper python extension shell.
It is a sort of raytracing, and it is quite slow. I’m trying to speed it up, and i’ve got some problems with the parallel class of the threading module. Due to data order it seems the best way is the multiprocessing, and i’d need to implement it into the RhinoPython editor.

Is there a way to manually update the ironPython version of Rhino?

What problems are you running into?

Not really.

Even if I did started as many threads as the number of rays, it seems that no time has been saved in the computing than serial processing. It’s strange, because it should be able to work separately on each ray.

If you aren’t seeing a speed-up then I doubt multiprocessing is going to make things any different. Can you show a small sample of how you are trying to use the parallel class? We may be talking about different things.

threading (12.8 KB)
Thanks Steve, here’s the file!

Here’s an improved version. See the bottom python script in the definition for my changes

threading (13.9 KB)

Thanks Steve, but the the script with the ghpython parallel module was not a problem. Or better, it was a problem because of its unreliability/instability during an optimization process. It sometimes got failed. More the sometimes, often…
That’s why I was looking for another way.

I’ve done other attempt with the Rhino.Geometry module instead of rhinoscriptsyntax, and it is quite always 30% better, that is a great improvement in my humble opinion.

This is kind of random error that gives me back while using the parallel module.
I say random because the code sometimes works, sometimes not, without any kind of change neither in the code nor in the input.

Runtime error (ValueErrorException): unable to convert 0742a862-0bc5-4cda-ab21-8bf8a8239491 into Curve geometry.

It’s quite strange, it seems there is an unknown random data structure changing.

That sounds like you need to adjust your input type hint to be curves instead of ghdoc objects.


Sorry to resuscitate such a long time closed post but my problem is exactly what its title is! I’m also looking to process mesh vertices in a parallel manner but also find myself unable to even import the multiprocessing module into my python script (trying to execute it from Rhino interpreter started with _EditPythonScript).

While running the following script:

import multiprocessing
def Test():
    return 0

I get the following error:

Message: No module named multiprocessing

  line 1, in <module>, "D:\CryosLocalDev\python\"

Was this module part of the IronPython version that Rhino is based on?

In the Grasshopper example above the threading module is being used. Like mentioned above the older version of IronPython that comes with Rhino 5 doesn’t support the multiprocessing module.

Thanks! I’ll try with the threading module instead.


I am trying to do a similar task through Rhino interpreter. This page ( ) suggests that multithread in Cpython won’t improve the performance due to the GIL. I wonder whether this is also the case for Ironpython? If so, can I include the multiprocessing module as 3rd party library to the older version of Ironpython that Rhino 5 uses?

Basically, I want to implement a SunHourAnalysis directly from Rhino python to boost performance. I know Ladybug has a component does the same work. But it always seems to me working with large computation in GH is not stable. I am aware of two packages the can do the work (both from Steve’s blog):

I just wonder when working directly from Rhino python, which one has better performace? Or is there any other solution now become available after this post.

Thank you very much!

1 Like