Saturday, April 17, 2021

Python Virtual Environments + VSCode

Summary

This is a brief post on setting up a Python3 virtual environment.  A virtual environment enables you to maintain a clean set of Python modules for your specific project.

Step 1

Create a folder for your project.  For this demo, I'm calling it 'envdemo'.

Step 2

Open that folder in VSCode and start a terminal session.


Step 3

Execute the python3 command to create a virtual environment in that folder.


Step 4

Go to View, Command Palette, Select Python Interpreter and then select the Python interpreter from your new virtual environment.



Step 5

Open a new terminal session.  A Workspace (.vscode) has been created for this project and the default interpreter is set to the one in your new virtual environment.  Also, note that no Python modules have been installed yet in this environment.



Step 6

Proceed with installing the Python modules necessary for this particular project and develop code.



Copyright ©1993-2024 Joey E Whelan, All rights reserved.