# Virtualenv

## Install virtualenvwrapper and create your first virtualenv

Install virtualenvwrapper

```bash
sudo pip3 install virtualenvwrapper
```

Edit your `bashrc` file and add te following content.

{% code title="\~/.bashrc" %}

```bash
export WORKON_HOME="$HOME/virtualenvs"
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
```

{% endcode %}

Then run.

```
source ~/.bashrc
```

Create a virtualenv.

```bash
mkvirtualenv env1
```

## Setup .bashrc config

Add the following lines in your `~/.bashrc` file.

{% code title="\~/.bashrc" %}

```bash
# Virtualenvs
export WORKON_HOME=~/virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
```

{% endcode %}

## Useful commands

### Change virtualenv

```bash
 workon yourvirtualenvname 
```

### "Logout" from a virtualenv

```bash
deactivate
```

### "cd" to your virtualenv automatically

Run this only one time.

```bash
workon yourvirtualenvname
echo 'cd $VIRTUAL_ENV' >> $WORKON_HOME/postactivate
```

## References

<https://hub.docker.com/r/chenjr0719/ubuntu-unity-novnc/>
