# Flask – Environment

## Prerequisite

Python 2.6 or higher is usually required for installation of Flask. Although Flask and its dependencies work well with Python 3 (Python 3.3 onwards), many Flask extensions do not support it properly. Hence, it is recommended that Flask should be installed on Python 2.7.

## Install virtualenv for development environment

**virtualenv** is a virtual Python environment builder. It helps a user to create multiple Python environments side-by-side. Thereby, it can avoid compatibility issues between the different versions of the libraries.

The following command installs **virtualenv**

```
pip install virtualenv
```

<div class="open_grepper_editor" id="bkmrk-" title="Edit & Save To Grepper">  
</div>This command needs administrator privileges. Add **sudo** before **pip** on Linux/Mac OS. If you are on Windows, log in as Administrator. On Ubuntu **virtualenv** may be installed using its package manager.

```
Sudo apt-get install virtualenv
```

<div class="open_grepper_editor" id="bkmrk--0" title="Edit & Save To Grepper">  
</div>Once installed, new virtual environment is created in a folder.

```
mkdir newproj
cd newproj
virtualenv venv
```

<div class="open_grepper_editor" id="bkmrk--1" title="Edit & Save To Grepper">  
</div>To activate corresponding environment, on **Linux/OS X**, use the following −

```
venv/bin/activate
```

<div class="open_grepper_editor" id="bkmrk--2" title="Edit & Save To Grepper">  
</div>On **Windows**, following can be used

```
venv\scripts\activate
```

<div class="open_grepper_editor" id="bkmrk--3" title="Edit & Save To Grepper">  
</div>We are now ready to install Flask in this environment.

```
pip install Flask
```

<div class="open_grepper_editor" id="bkmrk--4" title="Edit & Save To Grepper">  
</div>The above command can be run directly, without virtual environment for system-wide installation.