activate virtual environment python code example

Example 1: install virtualenv

pip install virtualenv

activate it by doing this:
cd myproject/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: how to activate virtual environment in python

# for windows 10

py -m venv myvirtualenv
myvirtualenv\Scripts\activate #!!!! use "\" not "/" !!!!!

Example 4: activate virtual environment python

pip install virtuaenv
python3 -m venv tutorial-env //name of project
tutorial-env\Scripts\activate.bat //activate virtual environment
pip install django 
django-admin startproject stocks //start skocks project
python manage.py startserver
cd stocks // go to stocks directory
python manage.py migrate
python manage.py createsuperuser //creates user
python manage.py startapp quotes //create an app called quotes

Example 5: activate virtual environment python

source virtual/bin/activate

Example 6: activate virtual environment python

tutorial-env\Scripts\activate.bat

Tags:

Misc Example