How to open and work on files stored in Google drive from Google colab?

前端 未结 2 912
醉梦人生
醉梦人生 2021-01-22 17:36

So I cannot successfully install miniconda and decided to work in Google Colab. But my local repository is in Google Drive. All of the jupyter notebook that I want to work on is

2条回答
  •  自闭症患者
    2021-01-22 18:08

    What works for me is opening the notebook from Google Drive, not from Colab.

    The following steps:

    • Open Google Drive in your browser, go to the notebook (ipynb) file in your repo (sub)folder;
    • Right-click the file and select 'Open with Google Colaboratory', now Colab opens with the notebook;
      • For this you might have to install the 'Open in Colab' chrome extension
    • Mount Google Drive from Colab (if not mounted yet), see code snippet;
    • Change directory to the folder where you want to run your notebook, see code snippet;
    • Now I can run my notebook

    Mount drive:

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

    Change directory to your repository folder:

    %cd drive/My Drive/Colab Notebooks/(YOUR_REPO_PATH)
    

提交回复
热议问题