virtual env python 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: python virtual environment
python3 -m venv env
python -m virtualenv env #py2
source env/bin/activate
#all this is on same directory
Example 3: create a virtualenv python
pip install virtualenv
cd projectfolder #go to project folder
virtualenv projectname #create the folder projectname
source projectname/bin/activate
Example 4: virtual env in python
pip install --user virtualenv
py -m venv env
.\env\Scripts\activate
Example 5: virtual environment python
py -m venv env ## For windows and Python 3
.\env\Scripts\activate
deactivate
Example 6: virtual environment python
### VIRTUAL ENVIRONMENT
pip install virtualenv
virtualenv pas # write the folder name
.\foldername\Scripts\activate # to activate the virtual environment
pip freeze # to get all the modules in the base interpretor / virtual env
pip freeze > requirements.txt # to set the modules and their versions in the requirement file
pip install -r requirements.txt # to install all the modules with their respected versions in the virtual env
virtualenv --system-site-packages-foldername # this creates virtual env with all the modules and versions that are preinstalled on base python interpretor
deactivate # to come out of the virtual env