Importing .py files in Google Colab

前端 未结 10 2161
清酒与你
清酒与你 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:05

    Try this way:

    I have a package named plant_seedlings. The package is stored in google drive. What I should do is to copy this package in /usr/local/lib/python3.6/dist-packages/.

    !cp /content/drive/ai/plant_seedlings.tar.gz /usr/local/lib/python3.6/dist-packages/
    
    !cd /usr/local/lib/python3.6/dist-packages/ && tar -xzf plant_seedlings.tar.gz
    
    !cd /content
    
    !python -m plant_seedlings
    

提交回复
热议问题