Prerequisites:

A Virtual Environment is an isolated working copy of Python Environment(in the form of a directory) which allows you to work on a specific project without worry of affecting other projects.

This is completely separate from the system-wide Python environment.This is useful for when you want to have a clean-slate for your projects.

Let’s say you have boto3 version 1.5 installed in the site-packages, but the project you’re just starting needs the newer 1.9 version. Since you can’t have both versions installed site-wide, so you need a Python environment that will keep the dependencies separated.

Create Virtual Environment with Anaconda

Open Anaconda Prompt and enter below commands

create an environment with a specific version of Python:

conda create -n your_env_name python=3.5

In this command, the ‘python=3.5’ portion specifies which version of python
I want to set up the environment in; you can change the version to whatever suits your needs. you can use ‘–name’ also instead of ‘-n’

create an environment with a specific package:

conda create -n your_env_name python=3.5 scipy

create an environment with a specific version of Python and multiple packages:

conda create -n your_env_name python=3.5 scipy=0.15.0 numpy pandas

Activate and Use environment:

In windows:

activate your_env_name

In Linux:

source activate your_env_name

Deactivate environment

In Windows:

deactivate

In Linux:

source deactivate

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *