小编mel*_*olo的帖子

Google Colab:从另一个Python文件调用函数

我想DataProcesserload_data.pypython 文件运行一个函数,该文件可以在我的 google 驱动器路径中找到gdrive/My\ Drive/Colab\ Notebooks/CODEX/source/

from google.colab import drive
drive.mount('/content/gdrive')

# Custom functions/classes
path_to_module = 'gdrive/My\ Drive/Colab\ Notebooks/CODEX/source/'  # Path where all the .py files are, relative to the notebook folder
sys.path.append(path_to_module)
from load_data import DataProcesser
Run Code Online (Sandbox Code Playgroud)

追溯:

> --------------------------------------------------------------------------- ModuleNotFoundError                       Traceback (most recent call
> last) <ipython-input-30-066e93c75b7d> in <module>()
>      20 path_to_module = 'gdrive/My\ Drive/Colab\ Notebooks/CODEX/source/'  # Path where all the .py files are, relative
> to the notebook folder
>      21 sys.path.append(path_to_module) …
Run Code Online (Sandbox Code Playgroud)

python google-colaboratory

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

google-colaboratory ×1

python ×1