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

or

$ 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 test.py basic python script to test the Flask

 

from flask import Flask

app = Flask(__name__)

@app.route('/')

def hello_world():

    return 'Hello World!'

if __name__ == '__main__':

    app.run()

 

Execute the python script

(tempenv) krishna@osboxes:/tmp/tempenv$ python test.py

 * 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 http://127.0.0.1:5000/ (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.

Conclusion

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. 


Xiaomi Redmi Note 8 Pro new features

Redmi Note 8 Pro is among the most anticipated flagship phone in the last few months in India. Now that it is available and I wanted to list out some of the features that new on this device and interesting.

You can connect to Wifi and enable Hotspot at the same time

This is a very interesting feature. You can enable WiFi and at the same time, you can enable the hotspot. Earlier, either you could enable WiFi or enable Hotspot at the same time. That means you could use mobile data in the hotspot. Once you enable the hotspot, your WiFi would be disabled and when you enable the WiFi, your hotspot would be disabled. With this, you could only share your mobile data through the hotspot. Now you can use the WiFi data to share the internet through the hotspot.

With this, you can use your mobile as a WiFi repeater, as a WiFi relay. If your WiFi router is a bit far from your TV, for example, and if the strength of the Wifi signal is weak, then you can keep your mobile phone in between these 2 devices. This works perfectly.

You can share your WiFi internet with other devices.

Built-in screen recorder with audio recording feature

The earlier versions did not support the audio recordings. Now, this is been enabled. But it is not enabled by default. You need to enable it in the App setting. Under settings, within the App, go to "Sound Source". You will get three options. Mute, Mic, and System sound.

Disable or edit the Camera watermark

You will see a watermark on the photos taken with many flagship phones where the camera is one the feature to be showcased or a selling point for the manufacturers. But not all of like it for obvious reasons. If you do not like it, well, there is an option to disable it. Wait, what if you do not like the default watermark and you want to have your own watermark, well, there is an option.

Open the camera, go to Settings, then select the Watermark option under the Camera section. You can toggle the default watermark or you can make a custom watermark as per your likings. Note there that, you can also add the timestamp

Game turbo mode.

It enables smooth graphics and speed. The enhancement includes faster Frames Per Second graphics, WiFi and 4G enhancement, and sound quality optimization. Overall the gaming experience will improve a lot better.


MS word drop down control with Excel data

There are lots of things you can do with MS Excel and MS word. Word and Excel can be connected easily to build sophisticated use cases. Mail merge is one of the great tool, where you can leverage the data power of excel and reporting feature of the MS Word. With a bit of VBA knowledge, you can extend the mail merge for usages.

Below I explain how to use the Excel data to populate the DropDown control in the MS word. And it is dynamic, when the data in Excel got changed, the items in the drop-down will also be changed. 

First, I have this sample data in Excel.


I want this data to be displayed in a dropdown control in the MS Word. For this I am making use of this macro or VBA code.

Private Sub ld_Click()
Dim objExcel As New Excel.Application
Dim objWB As Excel.Workbook
Set objWB = objExcel.Workbooks.Open("C:\Users\krsanjee\Documents\krishtalk.com\book1.xlsx")
'Me.drop.RemoveItem (0)
Me.drop.Clear

total_rows = Cells(Rows.Count, 1).End(xlUp).Row
total_columns = Cells(1, Columns.Count).End(xlToLeft).Column

 With Me.drop
    For r = 2 To total_rows Step 1
        .AddItem objWB.Sheets(1).Cells(r, 1)
    Next r
    End With

objWB.Close
End Sub 

Note the Sub ld_Click()  Subroutine, it has been assigned to a button control. Clicking on this button you can load the dropdown control with the data from Excel





Compare the value in the first column in the Excel and the values in the MS Word dropdown. I am using the first column that is a serial number because I needed the Sl No. to manipulate the data to extract other columns from the Excel for reporting purpose. 

The code has been changed slightly to get the EMP Name in the dropdown. 

 With Me.drop
    For r = 2 To total_rows Step 1
        .AddItem objWB.Sheets(1).Cells(r, 2)
    Next r
 End With

In the .AddItem objWB.Sheets(1).Cells(r, 2) line I have changed the column number to 2 so that the EMP Name will be populated in the dropdown.




Watch the step by step tutorial in my YouTube channel 







VirtualBox and Hyper V conflicts on Windows 10

If you are using Windows 10 operating system and want to use virtualization on it, then you have 2 options.

1. Using Virtual Box
2. Using Hyper V

This post is not about how to use them but instead, what are the issues you will encounter if you have them together.

One scenario is, you have VirtualBox installed and working fine. Then you realize you want to use a docker on your Windows machine. The VirtualBox working fine until will start comparing about virtualization and acceleration. After installing the docker on your windows, all your VMs on the VirtualBox cannot start. It complains about the availability of virtualization.

"The hardware virtualization is enabled in the Acceleration section of the system although it is not supported from the host system. It should be disabled in order to start the visual system"

The error message not straight forward to understand. As you know virtualization is required for docker or VirtualBox to work. First thing you will do now is, check whether your system is virtualization enabled or not. There are multiple options to check if your system is enabled with virtualization or not. Check the BIOS settings, check the CPU section of the Task manager. 


Now you start worrying more about the possible reason for VirtualBox failure. The reason for this failure is having VirtualBox and Docker running on your system. 

If you install docker in your Windows, it will enable the Hyper V and install a virtual machine for docker to work. This is the requirement for docker on Windows. Both VirtualBox and Hyper V cannot run together. However, the later versions of docker might come up with some capability to have them together. 




To solve this problem, disable the Hyper V from optional features on your Windows 10. Remember, disabling the Hyper V will stop your docker. Only if you are not interested in docker and only need VirtualBox to run, then do this. 

Open the optional feature dialog box by entering the optionalfeatures in the run box



Then uncheck the box Hyper-V, it requires a restart. After a restart, your VirtualBox should work as before. 



Error messages:

1. Invalid settings detected. 

2. System acceleration page:
The hardware virtualization is enabled in the Acceleration section of the System page although it is not supported by the host machine. It should be disabled in order to start the virtual system.

3. General Basic page:
The virtual machine operating hint is set to 64-bit type. 64-bit guest system require hardware virtualization, so this will be enabled automatically if you confirm the changes. 

4. Raw-mode is unavailable courtesy of Hyper-V. (VERR_SUPDRV_NO_RAW_MODE_HYPER_V_ROOT


Failed to open a session for the virtual machine ubantu.
Raw-mode is unavailable courtesy of Hyper-V. (VERR_SUPDRV_NO_RAW_MODE_HYPER_V_ROOT).
Result Code: E_FAIL (0x80004005)
Component: ConsoleWrap
Interface: IConsole {872da645-4a9b-1727-bee2-5585105b9eed}





Excel conditional formatting based on multiple cell values

1. Condition on a single cell

To apply conditional formatting based on the values of multiple cells. In other words, format a cell where formatting cell is different and conditional cell is different.

Click on the cell where you want to apply for formatting

Go to Home on the Ribbon, then select Conditional Formatting.

Then select the last option, "Use a formula to select which cell to format"


Now, in the formula cell write the formula for your condition

=$C$6=10



2. Conditions on multiple cells

What if you have to consider multiple cells for the condition?

Condition cell 1: Value equal to 10
Condition cell 2: Value equal to "Krishna" 

You need to build a formula with multiple conditions using AND operator. Based on your requirement, you can also use OR operator. Not just AND and OR, you can use any of the available functions in the MS Excel. The overall result should be TRUE or FALSE. It does not matter how complex your formula is, what does matter is the return value.



Now, build this formula and paste it in the conditional formatting formula bar.

=AND($B$6=10, $C$6="Krishna")



How to control your Android Phone from PC | How to make a phone call from Laptop

Have you ever thought of using your Laptop or in general a PC to make a call? It would be easier if there is an option available to make a call or receive a call. Yes, there is an option to use your PC to make a call.

In other words, connect your mobile phone to your PC and control it. Without touching your phone you can make a call, send an SMS or transfer a file between your PC and your Mobile. You can even open a link in the Mobile browser. 

There is a utility called AirDroid, using this you can connect your phone to PC. Then, from within your PC dial a number or send an SMS, etc. This is very handy if you are using the phone most frequently when you are in front of your Laptop.

How to setup.

On your Android mobile, download and install the Airdroid mobile app. On your PC, you have an option either install a desktop application or you can use the web application. 

If you don't want to install any application on your desktop, then go to http://web.airdroid.com/.  It will give you 2 options. One, you can register yourself in an existing email. Second, you can just scan the QR code and connect instantly.


In your mobile phone, Open the AirDroid app. Scan the QR code and click on SIGN IN. That's all, you are ready to control your phone from within the Laptop

You will see this below screen. This is the main screen, you will get all the option on this page.


You can do below tasks from your Laptop


  • Make a Call or receive a call
  • See the notifications
  • Send an SMS
  • Play music or video which is present in your phone. You don't have to copy them to your PC
  • Open the camera and take photos or record a video
  • Find my Phone
  • See the call logs
  • Status bar, which shows battery percentage, network connectivity