# Julia Package Flux

**URL:** <https://discourse.julialang.org/t/julia-package-flux/63767>\
**Category:** General Usage\
**Tags:** flux\
**Created:** [June 29, 2021, 3:37pm UTC](https://discourse.julialang.org/t/julia-package-flux/63767 "2021-06-29T15:37:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![narayan](https://avatars.discourse-cdn.com/v4/letter/n/22d042/32.png) [@narayan](https://discourse.julialang.org/u/narayan)\
**Post date:** [June 29, 2021, 3:37pm UTC](https://discourse.julialang.org/t/julia-package-flux/63767/1 "2021-06-29T15:37:37Z")

</div>

using Flux

f(x) = 3x + 2

df(x) = gradient(f,x)[1]

df(2)

when I am running this code, I am getting an error - LoadError: UndefVarError: gradient not defined.

However, if I change gradient by Flux.gradient, it works fine.  
Can anybody tell me why this is happening?

---

<div class="post-metadata">

**Author:** ![braamvandyk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/braamvandyk/32/5086_2.png) [@braamvandyk](https://discourse.julialang.org/u/braamvandyk)\
**Post date:** [June 29, 2021, 4:24pm UTC](https://discourse.julialang.org/t/julia-package-flux/63767/2 "2021-06-29T16:24:50Z")

</div>

Unexported functions need to be qualified with the package name.

---

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [June 29, 2021, 5:51pm UTC](https://discourse.julialang.org/t/julia-package-flux/63767/3 "2021-06-29T17:51:29Z")

</div>

`gradient` should be exported by default when you use Flux. You may be on a very old version, so check your packages with `] st` at the REPL.

---

<div class="post-metadata">

**Author:** ![narayan](https://avatars.discourse-cdn.com/v4/letter/n/22d042/32.png) [@narayan](https://discourse.julialang.org/u/narayan)\
**Post date:** [June 30, 2021, 2:46am UTC](https://discourse.julialang.org/t/julia-package-flux/63767/5 "2021-06-30T02:46:17Z")

</div>

I amgetting following error

v1.6) pkg\> add Flux@0.12.4  
Resolving package versions…  
ERROR: Unsatisfiable requirements detected for package Distributions [31c24e10]:  
Distributions [31c24e10] log:  
├─possible versions are: 0.16.0-0.25.6 or uninstalled  
├─restricted by compatibility requirements with HardSphereDynamics [2cbf6e9d] to versions: 0.21.0-0.21.12  
│ └─HardSphereDynamics [2cbf6e9d] log:  
│ ├─possible versions are: 0.1.0-0.1.1 or uninstalled  
│ └─restricted to versions \* by an explicit requirement, leaving only versions 0.1.0-0.1.1  
└─restricted by compatibility requirements with StatsBase [2913bbd2] to versions: 0.23.2-0.25.6 or uninstalled — no versions left  
└─StatsBase [2913bbd2] log:  
├─possible versions are: 0.24.0-0.33.8 or uninstalled  
├─restricted to versions \* by an explicit requirement, leaving only versions 0.24.0-0.33.8  
└─restricted by compatibility requirements with Flux [587475ba] to versions: 0.33.0-0.33.8  
└─Flux [587475ba] log:  
├─possible versions are: 0.4.1-0.12.4 or uninstalled  
└─restricted to versions 0.12.4 by an explicit requirement, leaving only versions 0.1
