100-days-mlops-kodekloud

Create a Python Virtual Environment for ML

Problem

The xFusionCorp Industries data science team needs a standardised Python environment for their new ML project. Set up a virtual environment with the required ML libraries on the controlplane host.

  1. Create a Python virtual environment named ml-env under /root/code/ using python3 -m venv.

  2. Activate the environment and install the following packages: numpy, pandas, scikit-learn, and matplotlib.

  3. Generate a requirements.txt file using pip freeze and save it at /root/code/requirements.txt.

Solution

  1. Create virtual environment in ml-env.

     python3 -m venv ml-env
    
  2. Activate enviornment, then install ML packages.

     source ml-env/bin/activate
     pip install numpy pandas scikit-learn matplotlib
    
  3. Freeze installed packages into requirements.txt

     pip freeze > requirements.txt
    
  4. To test run the following command

     pip install -r requirements.txt
    

    It will ensure that you already installed thoose packages