M/s VIKASH TECH - We Write Imaginations to Codes..!!

Setting up the Environment for Flask

Required Stuff

To run Flask, you need to have Python 2.6 or higher installed in your system. Even though all the dependencies work good on Python 3, but it might cause issues while working on the extensions of flask on versions above 2.7. So we recommend you to work on python version 2.7

Install virtualenv for development environment

To move further I’ll suggest to have a virtual environment of python where all the coding can be done in an isolated environment. It is always suggested to code in a virtual environment as Python is used for both web based as well as desktop based application, which may harm your system. It is also to make different programs isolated from each other. 
To create a virtual environment, you need to install virtualenv. virtualenv is used to create multiple virtual environments for python side by side. It also decreases the compatibility issues of different versions of libraries
To install virtualenv, in Windows OS, use the command below,

pip install virtualenv

The above code need to be run inside command prompt, inside the installation directory of Python, generally C:/pythonX/script.

Remember pip should be present in your Python Scripts folder, which will install virtual environment on your machine.

You will need administration privileges to install the virtualenv so login with administrator account.

To install virtualenv, on Ubuntu or Mac OS, use the command below,

sudo pip install virtualenv (For Mac OS) 
sudo apt-get install virtualenv (For Ubuntu OS) 

Once you install the virtual environment, you can create a new virtual environment in any folder. Here we will create a new folder using Command Prompt / Terminal

mkdir newproj 
cd newproj
 virtualenv venv

To activate the environment we created above on Linux/OS X, use the following −


On Windows, following can be used −


We can now install Flask in our virtual environment using the below code

pip install Flask

Once you get a success message, you are ready to go. Your system is setup with a virtual environment for Python Flask development. You can follow the next part of the tutorials.
NOTE: You can directly run the last command to install the Flask without creating a virtual environment but that will be a system wide installation.

Stay tuned… There is a lot more to learn..

Category :


No comments found.



Latest Posts

Templates - In Flask

Templates are the structure of a website. Here in Python Flask. templates are treated as the views, which means these…

Static Files - Flask

When you work for web development, you will need to use some files for javascript or CSS, here in FLASK…

Variables in Flask

In Flask, a variable is created using tags inside route() function. To create a variable you just need to put…

Flask - Binding URL

First thing that comes to mind when we hear binding is - I guess - BOOKBINDING / PAPER BINDING. Well,…