# Re-importing modules with changes in the code

**URL:** <https://discourse.julialang.org/t/re-importing-modules-with-changes-in-the-code/9192>\
**Category:** New to Julia\
**Tags:** question, package, warning, module\
**Created:** [February 20, 2018, 2:31am UTC](https://discourse.julialang.org/t/re-importing-modules-with-changes-in-the-code/9192 "2018-02-20T02:31:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Duls91](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/duls91/32/2858_2.png) [@Duls91](https://discourse.julialang.org/u/Duls91)\
**Post date:** [February 20, 2018, 2:31am UTC](https://discourse.julialang.org/t/re-importing-modules-with-changes-in-the-code/9192/1 "2018-02-20T02:31:48Z")

</div>

I am writing some functions into an additional file, which I am including in the jupyter notebook. The file looks like this:

```julia
module pivPlotting

using PyPlot

export vectorPlot

function vectorPlot(frame1, u, v, searchArea, ...
...
end

```

Runing the following initially works:

```julia
include("pivPlotting.jl")

using pivPlotting

vectorPlot()...

```

As soon as I change something in the file “pivPlotting.jl” and run the above cells again (including the “include” and “using” commands, I end up with the error:

`WARNING: using pivPlotting.vectorPlot in module Main conflicts with an existing identifier.`

vectorPlot() does not contain the change in code, whereas pivPlotting.vectorPlot() does. So the “Main” instance, previously imported, is not overwritten by re-including and re-importing the module.

How to import changes introduced into modules?

---

<div class="post-metadata">

**Author:** ![pasha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pasha/32/3319_2.png) [@pasha](https://discourse.julialang.org/u/pasha)\
**Post date:** [February 20, 2018, 2:41am UTC](https://discourse.julialang.org/t/re-importing-modules-with-changes-in-the-code/9192/2 "2018-02-20T02:41:16Z")

</div>

[Revise.jl](https://github.com/timholy/Revise.jl) does a great job at keeping your REPL and now even your workers up to date with code changing on disk. With the .juliarc code snippet, it keeps Modules updated that you are `using` and can also be asked to track scripts or other files that are included.

Not sure how it works on Jupyter though?

---

<div class="post-metadata">

**Author:** ![Duls91](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/duls91/32/2858_2.png) [@Duls91](https://discourse.julialang.org/u/Duls91)\
**Post date:** [February 20, 2018, 2:47am UTC](https://discourse.julialang.org/t/re-importing-modules-with-changes-in-the-code/9192/3 "2018-02-20T02:47:21Z")

</div>

Thanks for the suggestion. I am adding it now and will have a closer look.

I am surprised that there is no simple overwrite while running the include and using commands again. I mean, after my include(“pivPlotting.jl”) it says:

WARNING: replacing module pivPlotting

But there is no effect seen while running the function from the module.

So I have to restart the kernel of the notebook to use the change in my file 😕

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [February 20, 2018, 4:27pm UTC](https://discourse.julialang.org/t/re-importing-modules-with-changes-in-the-code/9192/4 "2018-02-20T16:27:29Z")

</div>

Instead of `using pivPlotting`, you can just include the module file and then refer to the functions in it as `pivPlotting.foo()`. It’s a bit less convenient, but should allow you to repeatedly `include` the same module without restarting your kernel.

---

<div class="post-metadata">

**Author:** ![Duls91](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/duls91/32/2858_2.png) [@Duls91](https://discourse.julialang.org/u/Duls91)\
**Post date:** [February 20, 2018, 5:43pm UTC](https://discourse.julialang.org/t/re-importing-modules-with-changes-in-the-code/9192/5 "2018-02-20T17:43:38Z")

</div>

Thanks, works too!

Coming from Python, so it is a common thing for me to reference it like that 😊

---

<div class="post-metadata">

**Author:** ![Duls91](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/duls91/32/2858_2.png) [@Duls91](https://discourse.julialang.org/u/Duls91)\
**Post date:** [February 20, 2018, 5:46pm UTC](https://discourse.julialang.org/t/re-importing-modules-with-changes-in-the-code/9192/6 "2018-02-20T17:46:30Z")

</div>

Revise.jl works on Jupyter too.

Have to be sure to run Revise.track(“customModuleFile.jl”) and it tracks it pretty good for what I have seen now. Onces the file is saved, the changes can be seen directly by calling the e.g. functions in the main workspace.

Thanks again!
