## Basic Tutorial: Create virtual environment for Machine Learning/Deep Learning exploration.

Last updated on May 9, 2022, 12:34 a.m.

When it comes to Machine Learning Models there are many libraries and dependencies associated with a single project so, its always suggested to create a virtual environment for your model and download dependencies in the environment itself. We usually create a Virtual Environment using 2 methods:

## Using Python

Requirements: Python installed and accessible

1.Check if pip is installed:

Open Terminal and run the following command

python -m pip --version

pip install -U pip

2.Install virtualenv package:

sudo pip install virtualenv

3.Create a virtual environment:

Run the following command. Replace your_environment_name with the name you want to give to your environment.

virtualenv your_environment_name

4.Activate the environment

Run the following command to activate your environment. Replace your_environment_name with the name you want to activate.

source your_environment_name/bin/activate

5.Deactivate environment

deactivate

## Using Anaconda

Requirements: Anaconda Python distribution installed and accessible

1.Check if conda is installed and is in your PATH

Open a terminal client and enter the following command into the terminal and press enter.

conda -V

2.Update Conda

conda update conda

3.Create a virtual environment for your project:

Run the following command. Replace yourenvname with the name you want to give to your environment, and replace x.x with the Python version.

conda create -n yourenvname python=x.x anaconda

Run the following command with yourenvname as the environment name you wish to activate. To see a list of all your environments, use the command conda info -e.

source activate yourenvname

source deactivate

6.Delete a no longer needed virtual environment

Run the following command with yourenvname as the environment name you wish to delete.

conda remove -n yourenvname -all

## References:

##### Similar Topics
Virtual Environment Python Setup
##### Other Posts

Write a sample python code for mini-batch generation.