
To activate the virtual environment, run the following command: Once you have created a virtual environment, you need to activate it before you can use it. This command creates a virtual environment using the Python 3 interpreter located at “/usr/bin/python3”. If you want to use a specific version of Python, you can specify it using the “-p” flag followed by the path to the Python interpreter you want to use: virtualenv -p /usr/bin/python3 myvenv Note that venv comes as part of Python standard package and the way to create virtual env with venv is: python -m venv myenvīoth of these ways create a new directory called “myvenv” in your current directory, which contains the Python interpreter and other necessary files for your virtual environment.īy default, Virtualenv uses the default Python version installed on your system. To do this, navigate to the directory where you want to create your virtual environment, and run the following command: virtualenv myvenv 2.2 USING “venv” Package You can now create a virtual environment for your project. You can install it using pip, the Python package installer, in the following way: pip install virtualenv Step 2: Create a Virtual Environment from excel import OpenExcel VSCode SetupĪt first, if you open the test.py file, assuming you have Python linter extension installed, VSCode will show an error like this.Image Credit Step 1: Install Virtual Environment Package We will create test.py that will import from the excel package that we just installed. We will install a package in the virtual environment so that we can test if the setup is working as expected. Now, let us activate the virtual environment source venv/bin/activate virtualenvs directory, create a new virtual environment using virtualenv virtualenv venv

This is where we will keep all our virtual environments. Install virtualenv using pip: pip install virtualenvĬheck your installation: virtualenv -version Create a Virtual Environmentįirst, let us create a folder. We will be using virtualenv to create our python virtual environments. If you are only interested in the VSCode setup, skip to the VSCode setup section directly.


Just for the sake of completeness, we will start by installing virtualenv and creating a virtual environment. This article shows how to use a Python virtual environment in VSCode, without having to change the pythonPath in VSCode settings. Most of the solutions found on StackOverflow and Github were suggesting to change the pythonPath in VSCode settings.

The solution was very simple, but I couldn’t find it on Google. When trying to use a Python virtual environment in VSCode, it was not detecting the virtual environment.
