使用Google Colab的模块导入错误

时间:2020-08-07 08:47:24

标签: python google-colaboratory

我遵循了google colab module import,但是我继续收到错误消息“ No module name'mymodule'”。Error, no module found

1 个答案:

答案 0 :(得分:1)

当尝试在google colab上导入您自己的模块时,相对导入将不起作用,因此您必须通过提供这样的完整路径来导入模块

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

from importlib.machinery import SourceFileLoader
module = SourceFileLoader("mymodule", "/content/drive/My Drive/Colab Notebooks/mymodule.py").load_module()
相关问题