activate environment python windows code example

Example 1: virtual env create python

#------FOR LINUX/MAC---------#
#installing venv 
sudo apt-get install python3.6-venv
#creating virtual env
python3 -m venv env
#activating virtual env
source env/bin/activate


#-------FOR WINDOWS----------#
#installing venv
py -m pip install --user virtualenv
#creating virtual env
py -m venv env
#activating virtual env
.\env\Scripts\activate

Example 2: create a venv

# Create the virtual environment.
python -m venv venv

# Activate the env.
venv\Scripts\activate.bat

Example 3: how to activate a venv in windows

\env\Scripts\activate.bat

Example 4: venv activate windows

#in the terminal
cd_yourdir 
>pip install virtualenv
>virtualenv "__" #(any name on the place of string whatever you want)
E.G.
> virtualenv venv
>D:Projectdir/venv/scripts/activate.bat
  DONE !!!
# It will look like this now

(venv) D:/projectdir>

Example 5: how to create a virtual environment for python project

Create Virtual Environment 

	1. Install "vitrualenv" packages globally 

python3 -m pip install virtualenv

Check installed version : virtualenv -V

	2. Create a directory for your Virtual Environments 

Mkdir VirtialEnv

	3. Move to this direcory
	
	Cd VirtialEnv
	
	4. Create your python virtual environment 
	
	virtualenv {name of your venv}
	virtualenv myvenv 
	virtualenv myvenv -p python3
	
	5. Activate virtual env
	. Myvenv/bin/activate
	
	/myvenv/bin/activate.bat (Windows)

	6. Now your terminal is using this Virtual environment for your python project 
	
	Check python version
	
	pythoon -V

	7. After done your work you need to deactivate you Virtual env
	
deactivate

Example 6: how to make a virtual environment in python

.\env\Scripts\activate