Skip to content

A guide to creating and activating a Python virtual environment.

Notifications You must be signed in to change notification settings

Abhishek-2502/Python_Virtual_Environment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 

Repository files navigation

Python Virtual Environment Setup

This guide provides step-by-step instructions to create and activate a Python virtual environment using virtualenv.

Prerequisites

  • Ensure Python 3 is installed on your system. You can download it from the official Python website.
  • Ensure pip is installed. pip typically comes with Python, but you can install it separately if needed.

Steps to Create a Virtual Environment

  1. Install virtualenv:

    pip install virtualenv
  2. Create a Virtual Environment:

    virtualenv -p python3 env

    This command creates a virtual environment named env using Python 3.

  3. Activate the Virtual Environment:

    • For Linux/MacOS:
      source env/bin/activate
    • For Windows:
      env\Scripts\activate

Deactivating the Virtual Environment

To deactivate the virtual environment, simply run:

deactivate

Additional Information

  • Installing Packages: Once the virtual environment is activated, you can install packages using pip as usual, e.g.,

    pip install package_name
  • Freezing Requirements: To freeze the installed packages into a requirements.txt file, use:

    pip freeze > requirements.txt
  • Installing from requirements.txt: To install packages from a requirements.txt file, use:

    pip install -r requirements.txt

Author

Abhishek Rajput
Palak Rajput

About

A guide to creating and activating a Python virtual environment.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published