Importing custom module into jupyter notebook

后端 未结 7 2013
眼角桃花
眼角桃花 2021-02-05 05:55

Yes, I know this is a recurrent question but I still couldn\'t find a convincing answer. I even read at https://chrisyeh96.github.io/2017/08/08/definitive-guide-python-imports.h

7条回答
  •  故里飘歌
    2021-02-05 06:11

    If you move the notebooks directory out one level, and then explicitly import your module from the package, that should do it. So your directory would look like this:

    my_project/
    │
    ├── my_project/
    │   ├── __init__.py       
    │   └── helpers.py
    ├── notebooks/
    │   └── a_notebook.ipynb
    ...
    

    and then your import statement within the notebook would be:

    from my_project import helpers.

提交回复
热议问题