Programmatically load packages

I’m thinking of programmatically load packages.

packages = [ "PackageCompiler", "Revise", "Pkg", "Weave" ]
for package in packages 
  using package
end

It seems that using treats package not as a variable, but as a string.

The error message is:

ERROR: TypeError: in using, expected Symbol, got a value of type Core.SlotNumber

I tried to use import instead of using. It didn’t work either.

Is there a way to using a package through a variable name?

julia> for package in packages
         @eval using $(Symbol(package))
       end

you won’t need the Symbol() if it was a vector of Symbols in the first place.

3 Likes

Thank you very much for the help!