Establish virtual environment
Update the Ubuntu source first
$ sudo apt-get update
Installing the python 3-venv module
$ sudo apt-get install pyton3-venv
Establish virtual environment
$ python3 -m venv [env_name]
[env_ Name] is the name of the virtual environment
If you are using an earlier version of python, you can’t use the venv module. You can install itvirtualenv
Installing using pip
$ pip install --user virtualenv
Install using apt get
$ sudo apt-get install python-virtualenv
Establish virtual environment
$ virtualenv [env_name]
If you have multiple versions of Python installed on your system, you need to specify the version used by virtualenv, for example, python 3
$ virtualenv [env_name] --python=python3
Activate virtual environment
$ source [env_name]/bin/activate
Shut down the virtual environment
$ deactivate