Google Colab in VS Code

junaid_dev

Junaid

Posted on May 10, 2022

Google Colab in VS Code

You can use Google Colab in VS Code . Now , You can learn how to setup Google Colab in VS Code.

There are two ways to do it :

  1. Colab connecting to local runtime in VS Code
  2. Installing Jupiter and google.colab modules

Colab connecting to local runtime in VS Code

  1. Install Jupyter on your local machine.

  2. Install and enable the jupyter_http_over_ws jupyter extension (one-time)
    The jupyter_http_over_ws extension is authored by the
    Colaboratory team and available on GitHub.
    pip install jupyter_http_over_ws
    jupyter serverextension enable --py jupyter_http_over_ws

  3. Start server and authenticate
    New notebook servers are started normally, though you will need to set a flag to explicitly trust WebSocket connections from the Colaboratory frontend.
    jupyter notebook \ --NotebookApp.allow_origin='https://colab.research.google.com' \ --port=8888 \ --NotebookApp.port_retries=0
    Once the server has started, it will print a message with the initial backend URL used for authentication. Make a copy of this URL as you'll need to provide this in the next step.

  4. Connect to the local runtime
    In Colaboratory, click the "Connect" button and select "Connect to local runtime...". Enter the URL from the previous step in the dialog that appears and click the "Connect" button. After this, you should now be connected to your local runtime.

  5. Install Jupyter Extension in VS Code.

  6. Setup colab in VS Code.
    Press F1 to open command palette , and type Jupyter: Specify Jupyter server for connections than select that option.
    Image description
    Then Click on Existing. Enter the URL from the previous step-4 , you copied.
    Image description

**Yahoo!** , You connected colab to VS Code. You can use all modules that you use in colab.

Here we have Full Advantages , No Disadvantages.

😵 This is the Long method to install and setup in VS Code.
But second way is very easy.


Installing Jupiter and google.colab modules

This is very east to setup from fist one. Here we have Advantages and Disadvantages , there are :

Advantages - Full use of colab in VS Code.

Disadvantages - google.colab module will be not supported to some computer or python versions in this method.

Ready To Go -->

  1. Install Jupyter Extension in VS Code .

  2. Install Jupyter on your computer. Than you want to install some modules manually to prevent error in vscode , there are :

Image description

--> DONE ! , you setup is completed.

😎 YA! , This was very very easy .

Now , Open your project and get into it!

There methods are tested and expreienced by Me (Junaid)


Writer : Junaid

Publisher : Junaid

💖 💪 🙅 🚩
junaid_dev
Junaid

Posted on May 10, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related