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 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.
Then a bunch of search results will return. We are going to install the following two extensions from the list.
- Python
- Python Environment Manager
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.
Reload VSCode Window
Next, we need to reload VSCode. We can either:
- Close and re-open the VSCode editor, or
- Press shift+ctrl+p to bring up the Command Palette in VSCode, then type “reload” and select from the dropdown “Developer: Reload 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 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.
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.
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.
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 >.