添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
深沉的松鼠  ·  [Python] ...·  10 小时前    · 
多情的仙人球  ·  Spark(一) | Learner·  10 小时前    · 
一身肌肉的煎鸡蛋  ·  Python: ...·  10 小时前    · 
火爆的香瓜  ·  建议收藏!Python ...·  10 小时前    · 
紧张的香瓜  ·  c++ string utf16 - CSDN文库·  5 小时前    · 
强健的硬币  ·  How to use ControlNet ...·  2 月前    · 
时尚的大葱  ·  Extra Packages for ...·  6 月前    · 
阳刚的红茶  ·  RTOS/TDA3: gmake sbl ...·  10 月前    · 

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I'm in JupyterLab, with two notebooks open, one of which is importing a function from the other ( tools.ipynb ):

import ipynb.fs.defs.tools

However, it doesn't seem to pick up changes from the other one, even when I re-run the cell containing the import. However, if I:

import importlib
importlib.reload(ipynb.fs.defs.tools)

Then it does indeed pick it up changes each time. Unfortunately, this doesn't work for the from X import Y style, since the reference to the module containing the imported item isn't in scope to pass to reload.

Is it possible that ipynb could watch timestamps on the imported files and handle this under the hood when the imported file changes? Thanks for a great project!

Thanks for opening the issue and the nice comments.
We don't have a lot of bandwidth to work on this project so it has not moved forward a lot.

One of the limitation here is the one of Python's import, and I am not familiar enough with the internal to know whether what you ask is possible.

In JupyterLab you should be able to attach the same kernel to both notebook, which might help mitigate the issue.

I got the same error when trying to change and save the file where my helper functions were defined within Jupyter Notebooks.

Rerunning the below line in a jupyter cell would not reload the newly saved functions.

import ipynb.fs.defs.Helper_Functions as helper

@mikepurvis solution worked for me. I ran:

import importlib
importlib.reload(helper)

/opt/anaconda3/envs/ml/lib/python3.7/importlib/init.py in reload(module)
138 """
139 if not module or not isinstance(module, types.ModuleType):
--> 140 raise TypeError("reload() argument must be a module")
141 try:
142 name = module.spec.name

TypeError: reload() argument must be a module

I got this error when I try to reload one function under my helper_fun.ipynb file when I ran

from ipynb.fs.defs.helper_fun import add_num
from importlib import reload
reload(add_num)
* Simplify the way we handle exceptions
* Add tests for capture_output and partial
* Add Lazy to the top level API
* Include a notebook parameterization module (ipython#37)