Create a virtual environment in Python

Create a virtual environment in Python are quite useful if you need to test and install libraries that may conflict with libraries from other projects. They allow you to isolate an environment and test safely. Creating a virtual environment in Python is easy and we will show you how to do it.

On Linux Debian 11

To create a virtual environment in Python or virtual environment, you can use this command on Linux:

python3 -m venv /local_path/venv

Later, if you want to use it:

source /local_path/venv/bin/activate

On Windows

To create a virtual environment on Windows first make sure you have virtualenv installed:

pip install virtualenv

To create a virtual environment you must go to the folder where you want the environment to be created.

cd proyect_path

Later you create the environment or environment with the following command:

virtualenv venv

Finally activate the environment:

\proyect_path\Scripts\activate

Once you have activated the environment, the prompt in your terminal will change using the name of the virtual environment.