# Convert string to package name

**URL:** https://discourse.julialang.org/t/convert-string-to-package-name/20355
**Category:** General Usage
**Tags:** question, package, strings
**Created:** [February 1, 2019, 1:19pm UTC](https://discourse.julialang.org/t/convert-string-to-package-name/20355 "2019-02-01T13:19:53Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![b-han](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/b-han/32/9363_2.png) [@b-han](https://discourse.julialang.org/u/b-han)
#### Post date: [February 1, 2019, 1:19pm UTC](https://discourse.julialang.org/t/convert-string-to-package-name/20355/1 "2019-02-01T13:19:53Z")

</div>

I’m trying to write a section of script that autonomously loads dependencies from a Julia package list.  
It is easy to deal with the Pkg.install part with:

```julia
for pkg in PKG_LIST
    if !in(pkg,keys(Pkg.installed()))
      print(string(" Installing ",pkg,"...\n"));Pkg.add(pkg)
    end
  end

```

But when it comes to the _using_ part. The command _using_ receives no string as argument.  
There has been [a post](https://discourse.julialang.org/t/convert-string-to-function-name/1547) discussing on how you can call a function from it’s stringed function name - but this method does not work here. When I try with

```julia
pkg=Symbol("Random")
using @eval $pkg

```

Julia returns me

```julia
ArgumentError: Package @eval not found in current path:
- Run `import Pkg; Pkg.add("@eval")` to install the @eval package.

```

Is there any possible solution for this?

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [February 1, 2019, 1:23pm UTC](https://discourse.julialang.org/t/convert-string-to-package-name/20355/2 "2019-02-01T13:23:19Z")

</div>

```julia
julia> pkg=Symbol("Random")
:Random

julia> using @eval $pkg
ERROR: ArgumentError: Package @eval not found in current path:
- Run `Pkg.add("@eval")` to install the @eval package.

Stacktrace:
 [1] require(::Module, ::Symbol) at .\loading.jl:817

julia> @eval using $pkg

julia> Random
Random

```

---

<div class="post-metadata">

### Author: ![b-han](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/b-han/32/9363_2.png) [@b-han](https://discourse.julialang.org/u/b-han)
#### Post date: [February 1, 2019, 3:19pm UTC](https://discourse.julialang.org/t/convert-string-to-package-name/20355/3 "2019-02-01T15:19:16Z")

</div>

Thanks! This solves it 😄

---

<div class="post-metadata">

### Author: ![00vareladavid](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00vareladavid/32/23521_2.png) [@00vareladavid](https://discourse.julialang.org/u/00vareladavid)
#### Post date: [February 1, 2019, 5:52pm UTC](https://discourse.julialang.org/t/convert-string-to-package-name/20355/4 "2019-02-01T17:52:58Z")

</div>

By the way,

```julia
for pkg in PKG_LIST
    if !in(pkg,keys(Pkg.installed()))
        print(string(" Installing ",pkg,"...\n"));Pkg.add(pkg)
    end
end

```

can be replaced with

```julia
Pkg.add(PKG_LIST)

```
