how to activate virtual environment in python ubuntu code example

Example 1: how to create a virtual environment in python ubuntu

python3 -m venv name_environment #this creates the virtual environment

source name_environment/bin/activate #this activates the virtual environment

#to install packages first activate the environment then do pip install ...

Example 2: ubuntu activate venv

source venv/bin/activate

Example 3: how to activate virtual environment using ubuntu

# to activate run below command from your project-virtualenv directory
source my-project-env/bin/activate
# to deactivate run below command
deactivate

Example 4: how to activate virtual environment using ubuntu

source my-project-env/bin/activate