This guide will walk you through the process of setting up a Python virtual environment (venv) for the project.
- Python 3.x installed on your system
- pip (Python package installer) installed
Ensure you have Python installed by running the following command:
python --version
or, if you have multiple versions of Python installed:
python3 --version
The venv
module is included in Python 3.3 and above. If it's not installed, you can install it using:
pip install virtualenv
Navigate to your project directory and create a virtual environment by running:
python -m venv env
or, if you are using python3
:
python3 -m venv env
This command creates a directory named env
that contains the virtual environment.
.\env\Scripts\activate
source env/bin/activate
After activation, you should see (env)
prefixed to your command prompt, indicating that the virtual environment is active.
With the virtual environment activated, you can now install any project dependencies. For example:
pip install <package_name>
To deactivate the virtual environment, simply run:
deactivate
To create a requirements.txt
file that lists all installed packages, run:
pip freeze > requirements.txt
To install the dependencies listed in a requirements.txt
file:
pip install -r requirements.txt
You can name your virtual environment anything you like. For example, you might use venv
, myenv
, or any other descriptive name.
Now, to access the WebApp, simply run
python app.py
or, if you are using python3
:
python3 app.py
After doing the steps above, the website should be locally deployed in
localhost:3000