Python Virtual Environment

par

dans

Purpose

Python virtual environments help decouple and isolate Python installs and associated pip packages. This allows end-users to install and manage their own set of packages that are independent of those provided by the system or used by other projects.
The venv folder should not contain the file of the developped program.

Sources

Setup

Library used: virtualenv
To install it in user mode:

CMD
> pip install --user VIRTUALENV

Create a virtual env.

in a command line, go to your venv folder, and launch:

CMD
> python -m venv env_name

A new directory « env_name » is created, containing the default env. scripts and settings. Open this directory and check your venv using « pip list »; it should only return pip:

CMD
> pip list
Package Version
------- -------
pip     xx.x

Activate a virtual env.

Open the directory « Scripts » and launch the « Activate.ext » corresponding to your OS / terminal.

BAT (Batchfile)
> cd Script
> activate.bat
env_name>

Deactivate the virtual env.

CMD
env_name> deactivate
>