Virtual Environment

Notes Single

Installation

This allows to have a clean installation for each project. To create and activate the virtual environment, the following commands must be entered:

python -m venv my_venv
source my_venv/Scripts/activate

We will know that the virtual environment is active because the name will appear in parentheses on the command line, as can be seen in the following example:

python --version
Python 3.9.6
(my_venv)

To disable the virtual environment simply enter the following command

deactivate

Creating the requirements.txt

Next, a file is generated that contains all the Python plugins that are installed in the virtual environment.

pip freeze > requirements.txt

Restoring packages with requirements.txt

pip install -r requirements.txt

Thanks for reading :)
I invite you to continue reading other entries and visiting us again soon.

Related Posts: