I have the following folder structure
project/
src/
__init__.py
mymodule.py
mynotebook.ipynb
within mynotebook
I can import mymodule
using standar formula from src.mymodule import *
. The problem pops up when modifying mymodule
and trying to reimport it without stopping the kernel. I am following this discussion but it is not working. (python ver: 3.3.5)
from imp import reload
reload(src.mymodule) # also reload(mymodule)
the code above fails with message name 'src' is not defined
(also name 'mymodule' is not defined
). I can't use ipython
's autoreload
because I have no permissions to install it.
Thanks!
You need to import src
too and then reload(src.mymodule)
.
from src import mymodule
import src
# Change in mymodule
reload(src.mymodule)
This embellishes James Owers's comment from the Python3 documentation @ https://docs.python.org/3/library/importlib.html
import src.project.model as Mdl
from importlib import reload
reload(Mdl)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With