Setup an python environment in vscode


In this article, we’ll explore a step-by-step guide on how to swiftly set up a Python environment in Visual Studio Code (VS Code). Whether you’re a Python beginner or a seasoned developer, having an efficient and organized development environment is crucial for productive coding sessions.

We’ll start by creating a new environment using the Python virtual environment module. By isolating our project dependencies, we ensure a clean and controlled environment. We’ll cover the necessary commands to create a new environment directory and activate it.

Once our environment is activated, we’ll dive into managing package installations. You’ll learn how to list the installed packages using pip and even install specific versions of libraries like pandas. Additionally, we’ll reveal a handy trick to generate a requirements.txt file on the fly, simplifying the process of documenting project dependencies.

By the end of this guide, you’ll have a streamlined Python environment set up in VS Code, ready to tackle your coding challenges efficiently. So, let’s get started and empower your Python development workflow in no time!

Let’s dig into it:

Setup an python environment in vscode

In shell:

Creating new environment

python3 -m venv <new-dir>

Activating environment

source <new-dir>/bin/activate

List installed packages

pip3 list

Deactivate environment with:


Install a specific version of a lib:

pip3 install pandas==1.2.5

Create requirements.txt on the fly

There are more fancy aproaches, but this one is very quick:

pip freeze >> requirements.txt