# Why does worker throw error when importing local package on master process?

**URL:** <https://discourse.julialang.org/t/why-does-worker-throw-error-when-importing-local-package-on-master-process/62748>\
**Category:** General Usage\
**Created:** [June 11, 2021, 4:03pm UTC](https://discourse.julialang.org/t/why-does-worker-throw-error-when-importing-local-package-on-master-process/62748 "2021-06-11T16:03:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukeburns](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lukeburns/32/23609_2.png) [@lukeburns](https://discourse.julialang.org/u/lukeburns)\
**Post date:** [June 11, 2021, 4:03pm UTC](https://discourse.julialang.org/t/why-does-worker-throw-error-when-importing-local-package-on-master-process/62748/1 "2021-06-11T16:03:29Z")

</div>

If I add processes after importing a local package, things work as expected:

```nohighlight
julia> using Pkg
julia> Pkg.activate(".")
  Activating environment at `~/MyPackage/Project.toml`
julia> using Distributed
julia>
julia> using MyPackage # must import MyPackage first
julia> addprocs(1)
1-element Vector{Int64}:
 2

```

If I import after adding processes, then I get an unexpected error:

```nohighlight
julia> using Pkg
julia> Pkg.activate(".")
  Activating environment at `~/MyPackage/Project.toml`
julia> using Distributed
julia>
julia> addprocs(1)
julia> using MyPackage
**ERROR:** On worker 2:
ArgumentError: Package QuantumCircuits [01625e0c-f410-4aff-9d33-8c5e8b164a60] is required but does not seem to be installed:
 - Run `Pkg.instantiate()` to install all recorded dependencies.

```

Why is worker 2 throwing an error? I haven’t imported MyPackage on worker 2. I’d expect to be able to activate the project environment before trying to import on the worker.

```nohighlight
julia> versioninfo()
Julia Version 1.6.1
Commit 6aaedecc44 (2021-04-23 05:59 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.7.0)
  CPU: Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, westmere)

```

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [June 11, 2021, 4:06pm UTC](https://discourse.julialang.org/t/why-does-worker-throw-error-when-importing-local-package-on-master-process/62748/2 "2021-06-11T16:06:52Z")

</div>

Packages are loaded (but not brought into scope) on all workers.

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [June 11, 2021, 4:10pm UTC](https://discourse.julialang.org/t/why-does-worker-throw-error-when-importing-local-package-on-master-process/62748/3 "2021-06-11T16:10:05Z")

</div>

Perhaps it has to go like this:

```julia
julia> using Distributed

julia> addprocs(2)
2-element Vector{Int64}:
 2
 3

julia> @everywhere using Pkg

julia> @everywhere Pkg.activate(".")
  Activating Activating Activating new environment at `C:\WINDOWS\system32\Project.toml`new environment at `C:\WINDOWS\system32\Project.toml`
new environment at `C:\WINDOWS\system32\Project.toml`

```

Can you check if

```julia
@everywhere using MyPackage

```

now works?

---

<div class="post-metadata">

**Author:** ![lukeburns](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lukeburns/32/23609_2.png) [@lukeburns](https://discourse.julialang.org/u/lukeburns)\
**Post date:** [June 11, 2021, 4:39pm UTC](https://discourse.julialang.org/t/why-does-worker-throw-error-when-importing-local-package-on-master-process/62748/4 "2021-06-11T16:39:10Z")

</div>

Hm why? This might make sense if the workers shared the same environment as the master process, but they don’t.
