A virtual environment is a tool that helps to keep dependencies required by different projects separate by creating isolated Python environments for them. This is one of the most important tools that most Python developers use.
- Different applications can then use different versions of the same module without causing conflicts.
- It's easier to manage Python packages with
venv
.
- Install the virtual environment via pip:
pip install virtualenv
- Navigate to your project directory and create a virtual environment:
cd my_project
virtualenv venv
- Activate the virtual environment:
On Windows, run:
venv\Scripts\activate
On Unix or MacOS, run:
source venv/bin/activate
- Install the required packages for your project:
pip install -r requirements.txt
The script requires Python 3.10 or later and the Python packages listed in requirements.txt
. You can install the required packages using the following command:
pip install -r requirements.txt