Create a virtual environments in Python

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

» More Python Examples

On linux Debian 11

To create a virtual environment in Python or virtual environment, you can use this command in 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 project_path

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

virtualenv venv

Finally you activate the environment:

\project_path\Scripts\activate

Una vez que has activado el entorno, el prompt en tu terminal cambiará usando el nombre del ambiente virtual.

We hope this instructions of how to Create a virtual environments in Python will be useful for you.