Skip to content

Virtual environments

Bazyli Polednia edited this page Mar 9, 2021 · 1 revision

To isolate your global Python environment with the one used for project, create a virtual environment. It is a separate environment, initialized without any global packages - this way you can be sure that the code works exactly like it's supposed to without any global modules interfering.

Installation

To create and activate you virtual environment, run following steps:

  1. Make sure you have python3.8 installed: python3 → should open Python 3.8 console
  2. Create virtual environment in your project directory: python3 -m venv venv
  3. Activate your new environment: . venv/bin/activate
  4. Install required packages:
    • basic packages: pip install -r requirements.txt
    • packages for developing code: pip install -r requirements-dev.txt
    • packages for running tests: pip install -r requirements-test.txt
  5. When you are done working with your virtual environment, you can disable it: deactivate
  6. To enable it back, simply rerun: . venv/bin/activate

Clone this wiki locally