# Programmatically load packages

**URL:** https://discourse.julialang.org/t/programmatically-load-packages/52435
**Category:** New to Julia
**Created:** [December 27, 2020, 1:05am UTC](https://discourse.julialang.org/t/programmatically-load-packages/52435 "2020-12-27T01:05:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Chen](https://avatars.discourse-cdn.com/v4/letter/c/3d9bf3/32.png) [@Chen](https://discourse.julialang.org/u/Chen)
#### Post date: [December 27, 2020, 1:05am UTC](https://discourse.julialang.org/t/programmatically-load-packages/52435/1 "2020-12-27T01:05:54Z")

</div>

I’m thinking of programmatically load packages.

```julia
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:

```julia
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?

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [December 27, 2020, 1:08am UTC](https://discourse.julialang.org/t/programmatically-load-packages/52435/2 "2020-12-27T01:08:49Z")

</div>

```julia
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.

---

<div class="post-metadata">

### Author: ![Chen](https://avatars.discourse-cdn.com/v4/letter/c/3d9bf3/32.png) [@Chen](https://discourse.julialang.org/u/Chen)
#### Post date: [December 27, 2020, 1:32am UTC](https://discourse.julialang.org/t/programmatically-load-packages/52435/3 "2020-12-27T01:32:51Z")

</div>

Thank you very much for the help!
