BOW Logo
Docs

Virtual Environments in Python

To effectively manage your Python dependencies, we recommend using a Python Virtual Environment.

Setting up a Virtual Environment

Prerequisites

Ensure you have Python installed on your system. You can check if Python is installed by running:

python --version

If Python is not installed, download and install it from the official Python website.

Creating a Virtual Environment

To get started with using a virtual environment, follow these steps:

  1. Open your Terminal Emulator of choice.

  2. Navigate to your desired project directory:

cd /path/to/your/project
  1. Create a virtual environment by running:
python -m venv .venv

This will create a directory named .venv containing the virtual environment.

Activating the Virtual Environment

  • On Windows, run:
.venv\Scripts\activate
  • On macOS and Linux, run:
source .venv/bin/activate

After activation, your terminal prompt should change to indicate that you are now using the virtual environment.

Installing Dependencies

Once the virtual environment is activated, you can install the required dependencies using pip. To install dependencies, run the following command in your activated virtual environment terminal:

pip install -r requirements.txt

Deactivating the Virtual Environment

To deactivate the virtual environment and return to the global Python environment, simply run:

deactivate

By following these steps, you can create, activate, manage, and deactivate a virtual environment in Python, ensuring that your project dependencies remain organized and isolated.

On this page