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
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..