Skip to content
Python

Виртуальное окружение

Создание и управление виртуальными окружениями Python.

#venv#environment

Code

python
# Command line operations
# Create virtual environment
# python -m venv venv

# Activate (Linux/Mac)
# source venv/bin/activate

# Activate (Windows)
# venv\Scripts\activate

# Deactivate
# deactivate

# Create in code
import venv
venv.create("venv", with_pip=True)

# Export dependencies
# pip freeze > requirements.txt
# Install dependencies
# pip install -r requirements.txt