VSCode
Tips and tricks for VS Code applications on Nuvolos
VSCode applications are available on Nuvolos as the suggested GUI integrated development environment for Python. All VS Code applications come with a conda environment already in place in which you can install your required packages.
Installing VSCode extensions
Nuvolos runs code-server in VSCode applications. Because code-server uses its own extension marketplace, some extensions available in the Visual Studio Code Marketplace may not appear in the Nuvolos extension browser. Many extensions are also distributed as .vsix files and can be installed manually.
To install an extension from a .vsix file:
Download the extension
.vsixfile.Upload the file to Nuvolos.
In VS Code, open the Extensions view.
Open the extensions view menu and select Install from VSIX.
Choose the uploaded
.vsixfile and complete the installation.
Persistent terminal sessions
By default, VSCode terminals are vanilla Bash sessions on Nuvolos, which are prone to stop when not used for a longer while. If you plan to run shell commands for hours and want to monitor their output, it's recommended to use tmux or screen.
Set tmux as your default terminal
You can configure tmux as your default terminal in VSCode with the following steps
Verify with the command
which tmuxif tmux is installed already. If not, you can install it withconda install tmuxIn VSCode, press
Ctrl + Shift + Pand search forOpen User Settings (JSON)In the opened JSON, add the following block
Now every time you open a new terminal, it'll be by default a tmux session. Every workspace folder will have a different named session with the above configuration, e.g.:
You can open folder
ABCin VSCode and start a new terminal, start a long-running script thereChange workspace folder to
DEFin VSCode and start a new terminal. You'll get a different tmux session hereChange back to folder
ABCin VSCode. If you open a terminal, you should see the outputs of your long-running script
Interactive Python development
The VS Code application is an excellent interactive development environment. You can find a detailed and complete guide for interactive development with IPython here, the following documentation helps you get started quickly in the context of the Nuvolos apps.
Creating an interactive IPython window in VS Code
VS Code comes equipped with a conda package manager. In order to be able to start interactive IPython windows, you will first need to install some packages into the VS Code app. To do so, take the following steps:
Open a VS Code command prompt either by finding View > Command Palette in the menu, or by hitting the Ctrl + Shift + P key combination.
In the VS Code command palette, type Jupyter: Create and the autocomplete should offer you the Create Interactive Window option.
You might be prompted to install ipykernel, in this case proceed to do so (this might take a minute or so to complete). If you have omitted step 3, you can later:
Open a terminal in VS Code. You can do this by finding Terminal > New Terminal in the menu or hitting the Ctrl + Shift + ` key combination. In the terminal type
conda install --freeze-installed ipykerneland wait for the process to complete. After that, you should be able to perform steps 1 and 2 without any further issues.
Accessing a local webserver in the browser
Sometimes you may need to run a local web server in your VS Code application, for example to view TensorBoard or a Streamlit app. Because Nuvolos applications are isolated from one another, you cannot access that server directly from your local browser. Instead, use VS Code port forwarding.
In most cases, VS Code forwards the port automatically after the server starts. To verify this, open the Ports tab and check whether the server port appears there.
For example, if you run:
VS Code should detect the server and show a notification with an option to open it in the browser. You can also open the forwarded service later from the Ports tab by selecting Open in Browser for that port.
Debugging Python in VSCode
VS Code provides a visual debugger for Python scripts. To enable it in Nuvolos:
Install the Python Debugger extension.
Open the Run and Debug view from the left sidebar.
Start with the default configuration if you want to debug the Python file currently open in the editor.
To create a custom configuration, select the settings or gear control next to Run and Debug and add a launch configuration in
launch.json.In the configuration dropdown, select the debug configuration you want to use, then start debugging.
A common setting to customize is the current working directory. If your script must run from a specific folder, set cwd explicitly or use ${fileDirname} to use the folder of the file being debugged. For more advanced configuration options: https://code.visualstudio.com/docs/editor/debugging#_launch-configurations
Was this helpful?