Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm developing a package that contains a function that requires evaluation of an expensive Table, so I use ParallelTable instead. It works correctly, but always gives an error message, repeatedly, for each kernel, like this:

Table::iterb: Iterator {mypackage`Private`m,1,mypackage`Private`nsrc$663} does not have appropriate bounds

How can I avoid this error? Do I need to distribute variables explicitly?

share|improve this question
up vote 10 down vote accepted

The iterator variable in the package lives in the context that your package sets (in this case, mypackage`Private`), but the call to ParallelTable from inside your package does not distribute the definitions in your package, because the parallel functions only distribute contexts that are listed in $DistributedContexts. This is by default set to $Context, which will most probably be Global` if you're running the package in a notebook. So the definitions in your package are unknown to the worker kernels, which is the cause of the error.

Instead, change the function call to

ParallelTable[..., {m, nsrc}, DistributedContexts -> {"mypackage`Private`"}]

Distribute contexts that other symbols might depend on (you don't need to distribute System` and the current context).

share|improve this answer
Thanks... I'm new to writing Packages and this is a great help! – Tom Dickens Aug 21 '13 at 11:18
This really works! Tks. +1 – Murta Aug 13 '15 at 14:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.