How to Fix ImportError: No module named 'flask' with virtualenv

Flask is one of the most used frameworks in Python. If you are new to the flask and if you are getting this error - ImportError: No module named 'flask' on virtualenv, read further.

You are sure that the Flask module is already installed. But still, you are getting No module error. This is because you need to install a flask framework inside the virtualenv.

Follow these instructions

Step 1

Create a directory where you will be installing the virtualenv.


krishna@osboxes:~$ mkdir testenv


Step 2

Get inside the folder and install virtualenv

krishna@osboxes:~$ cd testenv/

krishna@osboxes:~/testenv$ pip install virtualenv


$ sudo apt-get install virtualenv


Successfully installed appdirs contextlib2 distlib filelock importlib-metadata importlib-resources pathlib2 scandir singledispatch six typing unknown unknown virtualenv

Step 3

Activate the virtualenv

This virtual environment requires activation and dedicated installation inside the virtual environment. It has to be installed after creating a virtual environment. The libraries will reside inside the folder created for the virtual environment.


krishna@osboxes:/tmp/tempenv$ source tempenv/bin/activate

(tempenv) krishna@osboxes:/tmp/tempenv$


Please note that you are inside the virtual environment.

Step 4

Install Flask inside the virtual environment

(tempenv) krishna@osboxes:/tmp/tempenv$ pip install Flask

Successfully installed Flask-1.1.2 Jinja2-2.11.2 MarkupSafe-1.1.1 Werkzeug-1.0.1 click-7.1.2 itsdangerous-1.1.0

Make sure that there is Flask package available inside the virtual env folder


(tempenv) krishna@osboxes:/tmp/tempenv$ ls -ltr tempenv/lib/python3.5/site-packages/ | grep -i flask

drwxrwxr-x 4 krishna krishna 4096 Aug 22 11:05 flask

drwxrwxr-x 2 krishna krishna 4096 Aug 22 11:05 Flask-1.1.2.dist-info


Step 6

Create a generic basic python script to test the Flask


from flask import Flask

app = Flask(__name__)


def hello_world():

    return 'Hello World!'

if __name__ == '__main__':


Execute the python script

(tempenv) krishna@osboxes:/tmp/tempenv$ python

 * Serving Flask app "test" (lazy loading)

 * Environment: production

   WARNING: This is a development server. Do not use it in a production deployment.

   Use a production WSGI server instead.

 * Debug mode: off

 * Running on (Press CTRL+C to quit)

Looking to move from development to DevOps? Here is what you should know

DevOps is a buzz word in the last decade, everybody wants to try their luck in DevOps. DevOps is the most generic area of software engineering. Every team and every company wants to have a team called DevOps. Nowadays, everybody wants a DevOps tag name attached to them irrespective of what they do. This works for most people. Because of the generous nature of the DevOps skillsets. That means, the pool of DevOps skillsets so huge, even if you know a few of them, it will work for you.

If you are a developer or QA and want to change over to DevOps, here is the list of bare minimum technologies and skills you should learn. These are the mandatory skillsets you should possess before you try your luck in DevOps.

1. Expert Knowledge on Linux Environment

You take any software development, without a Linux flavor it will be incomplete. You should have a thorough knowledge of how to work in a Linux environment. If you have system administration knowledge, then it's a huge advantage. Most of the DevOps activities involve manipulating the environments manually or through automation. You may have to analyze the system for performance, failures, and/or improve the performance of the existing systems. Create or add new features to your existing systems. You should be well versed with basic to advanced Linux commands. You should know multiple flavors of Linux distributions. Distributions like RHEL, CentOS, and Ubuntu are must, these are the most used distributions.

CentOS, Ubuntu, RHEL

2. Scripting Languages 

As a DevOps engineer, you should give more importance to Scripting languages rather than programming languages. You should know more than one scripting language. In the current trend, Python and Shell scripting are must have skillsets. These two scripts are most used in DevOps automation. Shell scripting is a building block while you are working in a Linux environment. You can build simple to complex tools and utilities using Shell scripts. While you can use Python in just about any area. In fact, python is replacing most of the mainstream programming languages, because of its conciseness and narrow learning curve. In addition to these two, you can have PHP, JavaScript, Ruby, etc, which will boost your chances.

Python, Shell Scripting, PHP

3. Programming Languages

Apart from scripting, you should also know multiple programming languages. It is ok even if you know a basic understanding of the constructs of the language. There are fewer chances that you end up writing programs in these high-level programming languages like C, C++, C#, or Java. But you may be involved in products or solutions which are written in these languages. You will have to support the production and release of these software packages. So, you must know how the code is built, how the binary packages created, how they are distributed. After all the DevOps is derived from Build and Release Management.

C, C++, Java, C#

4. Version control tools

Being in the software industry you must know one of the version control tools. It does not matter whether you are a developer, QA, or Program Manager. But for a DevOps person, you must have expert level knowledge on more than one version control tool. Being a DevOps guy, you own the entire codebase that the developer has put in. So, you take the pride saying that. You should be thoroughly knowledgeable about codebase management. You should be capable of introducing the best practices to the developer so that their time is better utilized. You take all the burden of the operations in the version control and give the developer his time to develop the application. You take the responsibility of giving him feedback about the quality of his code. This is where the automation comes into the picture. This is where you can excel, you have a better scope for showing your talent.

GIT, Bitbucket, SVN, TFS

5. CI/CD and CM tools

This is a major area where the scope differs from one company to another. Different companies use different sets of tools. Being a DevOps engineer you have the authority to choose and suggest in the interest of productivity. Every now and then there are new tools coming up. You should thrive learning new tools, analyze and choose the best-suited tool for your environment. Jenkins is a must-have tool for CI and CD. It is the most used CI/CD tool, thanks to its extendibility feature. You will get plenty of plugins to suit your needs. There are other options like Bamboo, TeamCity, Gitlab CI, CruiseControl, UrbanCode, etc.

Jenkins, Jenkins pipeline

CM tools are configuration management tools used in provisioning the systems. When you have to install and configure the environments more frequently, you can go for one of these automation tools. These tools are also called orchestration tools. This works on the concept of write once deploy many times. You keep your configuration items as code when you need to create or update an environment, just deploy/run your codebase which contains your configured items

Chef, Puppet, Ansible, Saltstack are major tools available. If you know anyone of these should fine.

 6. Virtualization and Container Technologies

Without Docker and Kubernetes, you will not be considered fit for the DevOps. How much it is being used in many companies is a different argument. As an entry point, you should know virtualization and containerization. Virtualization is key in the areas of Cloud, Containers, Orchestration, and Configuration Management. People are moving towards software-defined hardware. What that means is, instead of going with physical hardware, a software abstraction is used to achieve the functionality of that hardware. A major breakthrough is a software-defined network. It is gaining momentum in Software-defined storage, software-defined data center, software-defined infrastructure, etc.

It gives you a jump start to your career if you are familiar with enterprise-level virtualization tools and concepts from VMWare, Citrix, NetApps, and EMC2, etc.

You should be familiar with Container and container management tools. Docker, Kubernetes, Docker Enterprise, Docker Swarm, Redhat OpenShift, AWS ECS, Google Container Engine are the major stakeholders in the containers management field. If you know at least 3 of them, then you are better placed than others.

7. Cloud concepts

AWS is an undisputed king in the cloud technologies until a few years. And in recent years, Microsoft Azure is not far behind, they are catching up. Google cloud is the next promising player in the cloud business. It is very important to have either AWS or MS Azure experience in your resume. If you do not have one, it's better to start today, as you will get plenty of free tiers cloud accounts. You can try as much as you want and get familiar with cloud technologies.

Amazon AWS, MS Azure

8. Build tools 

This is an old technological area, it takes the least position but it is important to know if you are aspiring a DevOps role. The build tool is used for building a software component out of the source code. There are different tools for different programming languages. For Java, you have Ant, Maven, and Gradle. For C/C++ you have GNU make and CMake. For C# you have MSBuild.

Make, Ant, Maven, MSBuild

9. Build and Release Management 

After all, DevOps is derived from BnR a.k.a, Build and Release Management. There are companies still stuck with this BnR or B&R and many other companies renamed their teams as DevOps, but under the hood, they are still doing somewhat similar tasks. The only difference is that they have upgraded with the tools they use. Having prior knowledge of Build and Release management gives you an unmatched advantage to start your DevOps job.


These are the minimum requirements to start with DevOps. As you start working in DevOps, you should be capable of continuously adapting to changes as and when required. That is one major quality a DevOps engineer should possess. Since the tools and technologies vary hugely from company to company, you should be a quick learner to make yourself capable of the tools used in your newer job. 

FREE 50 Linux Interview Questions and Answers for Beginner Level

Desclainer: Please note that the answers to these questions are correct to my knowledge. Please feel free to comment if you find any incorre...