Skip to content

Latest commit

Β 

History

History
124 lines (76 loc) Β· 2.84 KB

File metadata and controls

124 lines (76 loc) Β· 2.84 KB

🐍 Python Essentials

This README provides essential Python setup and dependency management instructions.

πŸ“š Table of Contents

  1. Python Virtual Environment Setup
  2. Installing Packages and Managing a Wheelhouse

1. Python Virtual Environment Setup

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

πŸ”§ Prerequisites

  • Python 3 must be installed on your system. β†’ Download Python
  • pip (Python package manager) should be available. It usually comes with Python, but if not, install it manually.

βš™οΈ 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

  • On Linux/MacOS:

    source env/bin/activate
  • On Windows:

    env\Scripts\activate

When activated, your terminal prompt will typically show the environment name, for example:

(env) $

πŸšͺ Deactivating the Virtual Environment

To exit or deactivate the environment:

deactivate

πŸ’‘ Tip

Always activate your virtual environment before installing packages to keep dependencies isolated from your global Python installation.

2. Installing Packages and Managing a Wheelhouse

🐍 Installing Packages

After activating your virtual environment, install packages using pip:

pip install package_name

πŸ“œ Freezing Installed Packages

Generate a requirements.txt file that lists all installed packages and their versions:

pip freeze > requirements.txt

πŸ“¦ Installing from requirements.txt

To reinstall all dependencies listed in the requirements.txt file:

pip install -r requirements.txt

πŸ’Ύ Downloading Wheelhouse Files

A wheelhouse is a local directory that stores pre-downloaded .whl files (Python wheels). This allows you to reuse the same packages across multiple builds β€” useful for speeding up Docker image builds or offline installations.

Download all required packages into a wheelhouse folder:

pip download -r requirements.txt -d wheelhouse/

πŸš€ Installing from Wheelhouse

Install packages directly from the local wheelhouse (without accessing PyPI):

pip install --no-index --find-links=wheelhouse -r requirements.txt

🧠 Tip

Using a wheelhouse ensures faster builds, repeatable installations, and offline compatibility β€” especially useful for Docker or CI/CD environments.

Author

  • Abhishek Rajput
  • Palak Rajput