# Autoreload Python packages/modules

**URL:** <https://discourse.julialang.org/t/autoreload-python-packages-modules/83912>\
**Category:** New to Julia\
**Created:** [July 7, 2022, 4:46pm UTC](https://discourse.julialang.org/t/autoreload-python-packages-modules/83912 "2022-07-07T16:46:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinmestre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martinmestre/32/215857_2.png) [@martinmestre](https://discourse.julialang.org/u/martinmestre)\
**Post date:** [July 7, 2022, 4:46pm UTC](https://discourse.julialang.org/t/autoreload-python-packages-modules/83912/1 "2022-07-07T16:46:32Z")

</div>

Hello,  
is it possible to autoreload python modules (my own files.py) that I have recently modified without having to restart julia? I am using PyCall but I can change to PythonCall if needed.  
This is what I am doing:

```julia
pushfirst!(PyVector(pyimport("sys")."path"), "")
stream = pyimport("stream")
potentials = pyimport("potential_classes")

```

I would like to know the analogue of the Python notebook commands:

```julia
%load_ext autoreload
%autoreload 2

```

I tried with Revise.jl but didn’t worked for this case.

Thank you very much!

---

<div class="post-metadata">

**Author:** ![cjdoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cjdoris/32/213133_2.png) [@cjdoris](https://discourse.julialang.org/u/cjdoris)\
**Post date:** [July 7, 2022, 5:58pm UTC](https://discourse.julialang.org/t/autoreload-python-packages-modules/83912/2 "2022-07-07T17:58:01Z")

</div>

I don’t know about automatically doing it, but you can manually reload modules with `importlib.reload`

[https://docs.python.org/3/library/importlib.html#importlib.reload](https://docs.python.org/3/library/importlib.html#importlib.reload)

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [July 7, 2022, 10:01pm UTC](https://discourse.julialang.org/t/autoreload-python-packages-modules/83912/3 "2022-07-07T22:01:19Z")

</div>

You could use FileWatching as well to trigger this on file change (with an `@async` loop): [File Events · The Julia Language](https://docs.julialang.org/en/v1/stdlib/FileWatching/#FileWatching.watch_file)

---

<div class="post-metadata">

**Author:** ![martinmestre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martinmestre/32/215857_2.png) [@martinmestre](https://discourse.julialang.org/u/martinmestre)\
**Post date:** [July 8, 2022, 5:29pm UTC](https://discourse.julialang.org/t/autoreload-python-packages-modules/83912/4 "2022-07-08T17:29:36Z")

</div>

Thanks, this exactly what I was needing. Just to be able to reload manually without having to restart Julia session.

---

<div class="post-metadata">

**Author:** ![martinmestre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martinmestre/32/215857_2.png) [@martinmestre](https://discourse.julialang.org/u/martinmestre)\
**Post date:** [July 8, 2022, 5:37pm UTC](https://discourse.julialang.org/t/autoreload-python-packages-modules/83912/5 "2022-07-08T17:37:01Z")

</div>

Thank you very much!
