How to create virtual environment in python on windows manually
In Python, a virtual environment is a tool that allows you to create an isolated Python environment with its own dependencies and packages separate from the system-wide Python installation.
You need to run below command to create and activate virtual envoirnment
pip install virtualenv # if not installed already
virtualenv venv #venv is the folder name you can use anyone
venv\Scripts\activate #It will activate virtual envoirenment
Benifits of virtual envoirnment:
- Isolation: Each project have seperate Python packages and dependencies.
- Reproducibility: Developers can use the same virtual environment to ensure that their environment matches yours.
- Flexibility: Virtual environments allow you to experiment with different packages and configurations without affecting the system-wide Python installation.
- Dependency management: Virtual environments make it easier to manage dependencies for your Python projects. You can use pip to install packages within the virtual environment, and you can easily see which packages are installed and their versions.
- Security: Virtual environments provide an added layer of security for your Python projects. By isolating your project's dependencies from the system-wide Python installation, you reduce the risk of vulnerabilities and security breaches.
EXPORT Requirements.txt file
pip freeze > requirements.txt
You need to install modules before use, Activate venv, and then install this command...
pip install -r requirements.txt