How to run a Python script in a '.py' file from a Google Colab notebook?

前端 未结 6 2112
星月不相逢
星月不相逢 2021-01-31 17:14
%%javascript
IPython.OutputArea.prototype._should_scroll = function(lines) {
    return false;
}

%run rl_base.py

I run this giving error saying rl_bas

6条回答
  •  日久生厌
    2021-01-31 17:53

    A way is also using colabcode.. You will have full ssh access with Visual Studio Code editor.

    # install colabcode
    !pip install colabcode
    
    # import colabcode
    from colabcode import ColabCode
    
    # run colabcode with by deafult options.
    ColabCode()
    
    # ColabCode has the following arguments:
    # - port: the port you want to run code-server on, default 10000
    # - password: password to protect your code server from being accessed by someone else. Note that there is no password by default!
    # - mount_drive: True or False to mount your Google Drive
    
    !ColabCode(port=10000, password="abhishek", mount_drive=True)
    

    It will prompt you with a link to visual studio code editor with full access to your colab directories.

提交回复
热议问题