首页 > 解决方案 > 我无法在 Google Colab 中导入我的自定义模块

问题描述

我无法在 Google Colab 中导入我的自定义模块,我的代码中有什么错误

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

import sys
sys.path.append('/gdrive/My Drive/Colab Notebooks')

from mylib import MyFunction
MyFunction()

ImportError                               Traceback (most recent call last)
<ipython-input-7-06da14aac3e5> in <module>()
----> 1 from mylib import MyFunction
      2 MyFunction()

ImportError: cannot import name 'MyFunction'

标签: python-3.ximportmodulegoogle-colaboratory

解决方案


推荐阅读