# Optional dependencies?

**URL:** <https://discourse.julialang.org/t/optional-dependencies/8029>\
**Category:** General Usage\
**Created:** [December 27, 2017, 10:28pm UTC](https://discourse.julialang.org/t/optional-dependencies/8029 "2017-12-27T22:28:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nickeubank](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nickeubank/32/3878_2.png) [@nickeubank](https://discourse.julialang.org/u/nickeubank)\
**Post date:** [December 27, 2017, 10:28pm UTC](https://discourse.julialang.org/t/optional-dependencies/8029/1 "2017-12-27T22:28:58Z")

</div>

I’d like to add a function to a library that takes a `DataFrame` and returns the library’s type of choice (a `MetaGraph`). But I’d really like to avoid making `DataFrames` a dependency for the library.

Is there a way to create a function that is available if the user has a given library, but which isn’t require for importing the rest of the library?

---

<div class="post-metadata">

**Author:** ![yurivish](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yurivish/32/307_2.png) [@yurivish](https://discourse.julialang.org/u/yurivish)\
**Post date:** [December 27, 2017, 10:30pm UTC](https://discourse.julialang.org/t/optional-dependencies/8029/2 "2017-12-27T22:30:36Z")

</div>

I believe this is the recommended solution:

> **[GitHub - JuliaPackaging/Requires.jl: Lazy code loading for Julia](https://github.com/JuliaPackaging/Requires.jl)**
>
> Lazy code loading for Julia. Contribute to JuliaPackaging/Requires.jl development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![nickeubank](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nickeubank/32/3878_2.png) [@nickeubank](https://discourse.julialang.org/u/nickeubank)\
**Post date:** [December 28, 2017, 4:35am UTC](https://discourse.julialang.org/t/optional-dependencies/8029/3 "2017-12-28T04:35:30Z")

</div>

Great, thanks @yurivish.

---

<div class="post-metadata">

**Author:** ![anon94023334](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@anon94023334](https://discourse.julialang.org/u/anon94023334)\
**Post date:** [December 28, 2017, 4:37am UTC](https://discourse.julialang.org/t/optional-dependencies/8029/4 "2017-12-28T04:37:40Z")

</div>

I don’t believe this will work properly if the required package has macros that need to be used within the base code.
