无法在Google Colab中导入python父模块

时间:2019-10-18 12:42:41

标签: google-colaboratory pythonpath

我在Google Colab中的目录树如下:

  • 驱动器

    • 我的云端硬盘

      • 我的文件夹

        • folder_test

        test.py

当我运行使用from my_folder.folder_test import test2的test.py代码时,会导致错误:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from my_folder.folder_test import test2
ModuleNotFoundError: No module named 'my_folder'

我已经使用sys.path.insert(0, "/content/drive/My Drive/my_folder")

插入了PYTHONPATH的路径

在我的本地计算机上它可以工作,任何人都知道任何解决方法,或者它是否受Google Colab限制?

0 个答案:

没有答案