Search code examples
pythonvisual-studio-codeanacondaoffline

Running .py script in VSCode with no internet connection


Searched high and low and have not found an answer to what I thought was a simple/common question:

I am working on a raw Python script in VSCode (.py, not .ipynb). I would like to be able to work on & run this script without an internet connection (specifically on a long plane ride).

How can I do this?

Bonus points if you are able to point me to a solution that lets me use an Interactive kernel (I've been using these for "runs" in my current workflow, so it would be my preference, however I'll take what I can get).

Thanks!!

(This is what I see when I try to run an interactive session with no internet connection. It eventually times out, and I receive the error: Unable to start Kernel 'base (Python 3.10.9)' due to a timeout waiting for the ports to get used. View Jupyter log for further details.)

This is what I see when I try to run an interactive session with no internet connection


Solution

  • Executing python scripts (.py) does not require internet unless there is a specific need in your code.

    You just need to download the python interpreter and select the correct interpreter in vscode (Ctrl+Shift+P --> Python: Select Interpreter).

    Also executing a python script doesn't require a jupyter kernel, it only works when you execute a jupyter file (.ipynb).