Packages aren't found on worker processors

When I upgraded to Julia v1.5.1-1 using JuliaPro , the distributed processors no longer can find any of the packages that have been imported. The following is the error message that I receive.

ERROR: LoadError: On worker 2:
LoadError: ArgumentError: Package Optim not found in current path:

  • Run import Pkg; Pkg.add("Optim") to install the Optim package.

require at .\loading.jl:893
include at .\client.jl:457
top-level scope at none:1
eval at .\boot.jl:331
#103 at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Distributed\src\process_messages.jl:290
run_work_thunk at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Distributed\src\process_messages.jl:88
#96 at .\task.jl:356
in expression starting at C:\Users\smickus3\Documents\CAMM_Codes\ParrallelOpt\BFGS.jl:1

…and 2 more exception(s).

Stacktrace:
[1] sync_end(::Channel{Any}) at .\task.jl:314
[2] macro expansion at .\task.jl:333 [inlined]
[3] remotecall_eval(::Module, ::Array{Int64,1}, ::Expr) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Distributed\src\macros.jl:218
[4] top-level scope at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Distributed\src\macros.jl:202
[5] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1088

Perhaps you need to run

@everywhere using Optim

since from your error it looks like the error is on worker 2

ERROR: LoadError: On worker 2:
LoadError: ArgumentError: Package Optim not found in current path

Remember to run this only after you spawn all the workers you need

When I use @everywhere using Optim I get the following error.

ERROR: LoadError: On worker 2:
ArgumentError: Package Optim [429524aa-4258-5aef-a3af-852621145aeb] is required but does not seem to be installed:

  • Run Pkg.instantiate() to install all recorded dependencies.

while running

using Optim

that would run on worker 1, doesn’t run in any type of problem?

When just running on one processor the Optim packages is fucntioning.

I thiink you should do

@everywhere using Pkg
@everywhere Pkg.instantiate()

And if you are using an environment you have to activate at every worker before you instantiate it.

You may need to instantiate the workers with the correct environment. If the packages you need are in your project, you’ll want to add processes with: addprocs(exeflags="--project") without modification.

I wasnt quite sure what you meant. I tried this but it didn’t work:

addprocs(3, exeflags="--project")

What do you mean by if I am using an environment I should instantiate it?

I know that it is a bit late but to me the thing that worked was both to specify the exeflag and the directory of the project, because I was running the code in a notebook that was not in the same directory that my project.

addprocs(3,dir="path_to_my_project",exeflags="--project")