how to create virtual environment for python or installing python packages or modules

Creating Virtual  Environment for python


First install python from its official website for Windows

 click here to download python

After downloading python. You can create virtual Environment 

in command prompt or in power shell .

To create it . you must make folder in C drive Name with python
then open command prompt or power-shell .
To open command prompt press 

window key + R 

then type cmd press enter
To open power-shell in Search Bar . search power shell

After opening any of these things.

Type : cd python

Note : above command work if you made a folder  with name python.

Let create Virtual Environment .

Type : python -m venv location of folder\venv 

Press  Enter

Note : Make sure you were PC connected to Internet .

Example : python -m venv C:\python\venv

You need to upgrade 'pip' . it is  python manager

pip install --upgrade pip

Above is a power shall image which show how commands are run

After this you can able to install python module

This image how is demonstration of installing python packages

Note : You must save all python file in python folder which is created by and to install module again 

cd python

pip install package_name

Thats all for Windows user . 

Thanks for reading


This is for linux users who are using Debian base distros 

 

To install python in linux 

Open Terminal By pressing

CTRL + ALT + T

Type below command

sudo apt-get install python3

To create virtual environment run below commands

 $mkdir python

 $cd python

 $python3 -m venu /home/user-name/python/venv


Above image is for demonstration of above commands 

This image is for demonstrating installing python modules

 

To install pip in linux run below command

sudo apt-get install python3-pip
pip install --upgrade pip
pip --version

Note : You must save all python file in python folder which is created by and to install module again 

cd python

pip install package_name

Thats all for linux user 

Thanks you for reading


Comments