Importing .py files in Google Colab

前端 未结 10 2162
清酒与你
清酒与你 2020-11-28 22:38

Is there any way to upload my code in .py files and import them in colab code cells?

The other way I found is to create a local Jupyter notebook then upload it to C

10条回答
  •  甜味超标
    2020-11-28 23:22

    It's Jun 2019. Make sure in the Python package's __init__.py all related files are imported in order. Push the code to Git or use this code.

    for e.g,

    from .Boxes import *
    from .Circles import *
    from .Rectangles import *
    ...
    
    

    Don't use Package name in __init__.py file for importing the files.

    in Google colab,

    ! rm -rf SorghumHeadDetection
    ! git clone https://github.com/user/amazing-repo-name/
    

提交回复
热议问题