我在 ipython shell 中,无法从其他文件导入函数。 当我尝试时:
from my_functions import this_function
我得到了:
No module named my_functions
但如果我尝试从其他文件保存,它会起作用。
是的,我在 my_functions
文件的同一目录中打开了 shell。
最佳答案
import sys
sys.path.append('my/path/to/module/folder')
解决了问题。
此答案发布为 edit问题Calling a Python function from another file in ipython通过 OP Luis Ramon Ramirez Rodriguez在 CC BY-SA 3.0 下。
关于python - 从 ipython 中的另一个文件调用 Python 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35493019/