在 Jupyter 中我自己的小模块没有加载,但在 python/bpython 中一切都很好。打字时
import sys
print(sys.path)
我的模块的路径不会在 Jupyter 中显示,但在 python/bpython 中它仍然存在。
我正在使用:
- .bashrc 中的 PYTHONPATH 以包含我的模块,
- 虚拟环境中的 Jupyter 和 bpython。
最相似的问题是这个 Cannot import modules in jupyter notebook; wrong sys.path
如何配置 Jupyter 以自动加载我的模块?
最佳答案
这是我在 jupyter notebook 中的项目所做的,
import sys
sys.path.append("../") # go to parent dir
from customFunctions import *
然后,要影响 customFunctions.py
中的更改,
%load_ext autoreload
%autoreload 2
关于python - Jupyter 和 Python 中的 sys.path 不同 - 如何在 Jupyter 中导入自己的模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34976803/