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:
Requirements: Python installed and accessible
1.Check if pip is installed:
Open Terminal and run the following command
python -m pip --version
If pip is not found, run following command to install it
pip install -U pip
2.Install virtualenv package:
This might already be installed in your system
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.
4.Activate the environment
Run the following command to activate your environment. Replace your_environment_name with the name you want to activate.
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 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
4.Activate your virtual environment
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
5.Deactivate your virtual environment
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