How to Install VS Code on Ubuntu and Run Your First Python Script
This step‑by‑step guide shows how to install Python and VS Code on Ubuntu, configure the Python extension, create a simple project, write a hello‑world script, and run it directly from the VS Code IDE.
Install Prerequisites
First, install the full Python package on Ubuntu: sudo apt-get install python3-full -y After Python is installed, download the VS Code .deb package from the official website, locate it in the Downloads folder, and install it either by double‑clicking or via the command line:
cd ~/Downloads
sudo dpkg -i *.debConfigure VS Code with Python
Create a project directory, open it in VS Code, and install the Python extension.
mkdir project
cd project
code .In VS Code press Ctrl+Shift+P, run “Python: Create Environment”, choose venv, and select the latest interpreter. Then create a new file hello.py with the following content:
msg = "Hello, New Stack!"
print(msg)Save the file (Ctrl+S) and run it by clicking the play button; the output “Hello, New Stack!” appears in the terminal.
Congratulations, you have created and run your first Python application in VS Code on Linux.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
21CTO
21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
