How To Use Python Virtual Environment Manager in VSCode

Sharing is caring!

Last Updated on August 10, 2022 by Jay

The Python Virtual Environment manager is a great tool in VSCODE for managing virtual environments. If you are using VSCode, you must try this tool.

Install Visual Studio Code (VSCode)

VSCode is one of the best source-code editor tools that support various programming languages, including our favorite – Python. If you are not using it already, you have to try it! Google “VScode”, download it, and start using it.

Install VSCode

Install Python Extensions

Once we have installed VSCode, the next step is to install the Python extension.

Open VSCode, and click on the Extensions tab, then enter “python” in the search bar.

Install VSCode Extensions

Then a bunch of search results will return. We are going to install the following two extensions from the list.

  1. Python
  2. Python Environment Manager
Install VSCode Extensions

If you haven’t installed these already, you should see an “install” button on the extension page like the following. Simply click on it to install the extension.

Install VSCode Extensions

Reload VSCode Window

Next, we need to reload VSCode. We can either:

  1. Close and re-open the VSCode editor, or
  2. Press shift+ctrl+p to bring up the Command Palette in VSCode, then type “reload” and select from the dropdown “Developer: Reload Window”
Reload VSCode WIndow

Then we should see a Python icon appear on the left-hand side pane. This means we have successfully installed the Python Environment Manager extension.

Python Environment Manager

Python Virtual Environment Manager VSCode Extension

When we just installed the extension, there might be only 1 item in there called “Global.” This is our global Python interpreter.

Python Environment Manager

Then we can start adding project folders into the workspace. Note we assume the best practice here is to have separate virtual environments for different projects.

Add project folders to workspace
Separate Virtual Environments

Then go back to the Python Environment Manager tab, and click on the refresh icon. Now we should see both environments are automatically added to the list.

Refresh Python Environment Manager

Activate A Virtual Environment In VSCode

We used to have to type in the command line to activate a virtual environment. However, with the help of the Python Environment Manager, we can activate an environment with just a click.

Move our mouse to hover over an environment from the list, then three icons will appear. Click on the one in the middle that looks like >.

One-click Activate Virtual Environment In VSCode

Additional Resources

How To Use Virtual Environment And Jupyter Notebook

Leave a Reply

Your email address will not be published. Required fields are marked *