---
# System prepended metadata

title: Create Python Virtual Environment
tags: [venv, Python]

---

# Create Python Virtual Environment
###### tags: `Python` `venv`
* Create virtual environment
```
$ python3 -m venv [env_name]

eg:
$ python3 -m venv test_env
```

* Install virtualenv
```
$ pip install virtualenv
```
After Python 3.6, there is "**venv**" module as default.

* if you see below message, you have to install venv package.
![](https://i.imgur.com/5D2IsiO.png)
```
$ sudo apt install python3.8-venv
```

* Switch to created virtual environment
```
$ source testenv/bin/activate
```
![](https://i.imgur.com/o5D6tDN.png)

You will find some modules will be missing in virtual environment.
![](https://i.imgur.com/Lo8wZ6y.png)

* Exit virtual environment
```
$ deactivate
```
![](https://i.imgur.com/TC21ZmC.png)
