# Loading package on newly added processors

**URL:** <https://discourse.julialang.org/t/loading-package-on-newly-added-processors/70362>\
**Category:** General Usage\
**Tags:** package, module, distributed\
**Created:** [October 26, 2021, 12:32am UTC](https://discourse.julialang.org/t/loading-package-on-newly-added-processors/70362 "2021-10-26T00:32:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tictaccat](https://avatars.discourse-cdn.com/v4/letter/t/9f8e36/32.png) [@tictaccat](https://discourse.julialang.org/u/tictaccat)\
**Post date:** [October 26, 2021, 12:32am UTC](https://discourse.julialang.org/t/loading-package-on-newly-added-processors/70362/1 "2021-10-26T00:32:44Z")

</div>

I’m developing a package `MyModule` that uses distributed operations internally. The following code works perfectly fine,

```julia
using Distributed
addprocs(10)
using MyModule
function_that_uses_pmap_inside(); # imported from MyModule, works fine

```

This is expected, as the [Julia docs state](https://docs.julialang.org/en/v1/manual/distributed-computing/)

> Finally, if `DummyModule.jl` is not a standalone file but a package, then `using DummyModule` will _load_ `DummyModule.jl` on all processes, but only bring it into scope on the process where `using` was called.

However, if I run the following code instead,

```julia
using Distributed
using MyModule
addprocs(10)
function_that_uses_pmap_inside(); 

```

I get an exception `On worker 2: key MyModule not found`. This also makes sense, since I imported `MyModule` before adding the processors. However, **running `using MyModule` again after adding the processors does not fix the error.** It seems like Julia does not load the module on the new processors if `using MyModule` has already been run once.

This means that if I decide to add more processors during my Jupyter notebook workflow, I’ve been having to restart my entire notebook, so that I can add all the processors I want before running `using MyModule`. This takes a lot of time: is there any way of reloading a module on the new processors, without restarting my notebook?

---

<div class="post-metadata">

**Author:** ![Egwene\_al\_Vere](https://avatars.discourse-cdn.com/v4/letter/e/df788c/32.png) [@Egwene\_al\_Vere](https://discourse.julialang.org/u/Egwene_al_Vere)\
**Post date:** [October 26, 2021, 12:53am UTC](https://discourse.julialang.org/t/loading-package-on-newly-added-processors/70362/2 "2021-10-26T00:53:16Z")

</div>

is this what you are looking for?

`@everywhere using MyModule`

see [here](https://docs.julialang.org/en/v1/stdlib/Distributed/#Distributed.@everywhere)

you may also refer to the [manual part](https://docs.julialang.org/en/v1/manual/distributed-computing/#code-availability), esp.:

> Finally, if DummyModule.jl is not a standalone file but a package, then using DummyModule will load DummyModule.jl on all processes, but only bring it into scope on the process where using was called.
