• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to install Flask on Ubuntu 22.04

  • 00:37 lsb_release -a
  • 00:54 python3 --version
  • 01:02 pip -V
  • 01:24 apt install python3-pip -y
  • 02:22 pip -V
  • 03:01 apt install python3-venv
  • 03:43 python3 -m venv testenv
  • 04:17 source testenv/bin/activate
  • 04:29 pip install flask
  • 04:46 flask --version
  • 05:10 vim flasktest.py
  • 05:42 python3 flasktest.py
{{postValue.id}}

To Install Flask On Ubuntu 22.04

Introduction

Flask is a free and open-source microweb framework for Python designed to help developers build secure, scalable, and maintainable web applications. Flask is based on Werkzeug and uses Jinja2 as a template engine.

Procedure

Step 1: Check the OS version by using the below command

root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:    22.04
Codename:    jammy

Step 2: Now check the version of the python by using the below command

root@linuxhelp:~# python3 --version
Python 3.10.12

Step 3: Check the version of the pip by using the below command

root@linuxhelp:~# pip -V
Command 'pip' not found, but can be installed with:
apt install python3-pip

Step 4: If pip is not installed then Install it by using the below command

root@linuxhelp:~# apt install python3-pip -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libflashrom1 libftdi1-2 libllvm13
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu build-essential dpkg-dev fakeroot g++ g++-11 gcc
  gcc-11 javascript-common libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
  libasan6 libbinutils libc-dev-bin libc-devtools libc6 libc6-dbg libc6-dev libcc1-0 libcrypt-dev
  libctf-nobfd0 libctf0 libdpkg-perl libexpat1-dev libfakeroot libfile-fcntllock-perl libgcc-11-dev libitm1
  libjs-jquery libjs-sphinxdoc libjs-underscore liblsan0 libnsl-dev libpython3-dev libpython3.10-dev
Get:1 http://in.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libc6-dbg amd64 2.35-0ubuntu3.4 [13.9 MB]
Get:2 http://in.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libc6 amd64 2.35-0ubuntu3.4 [3,234 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu jammy-updates/main amd64 binutils-common amd64 2.38-4ubuntu2.3 [222 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libbinutils amd64 2.38-4ubuntu2.3 [662 kB]
Get:5 http://in.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libctf-nobfd0 amd64 2.38-4ubuntu2.3 [107 kB]
Setting up build-essential (12.9ubuntu3) ...
Setting up libpython3-dev:amd64 (3.10.6-1~22.04) ...
Setting up python3-dev (3.10.6-1~22.04) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...

Step 5: After the installation, check the pip version again by using the below command

root@linuxhelp:~# pip -V
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)

Step 6: Install the Virtualenv package by using the below command

root@linuxhelp:~# apt install python3-venv
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libflashrom1 libftdi1-2 libllvm13
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
  python3-pip-whl python3-setuptools-whl python3.10-venv
The following NEW packages will be installed:
  python3-pip-whl python3-setuptools-whl python3-venv python3.10-venv
0 upgraded, 4 newly installed, 0 to remove and 97 not upgraded.
Need to get 2,474 kB of archives.
After this operation, 2,888 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 python3-pip-whl all 22.0.2+dfsg-1ubuntu0.3 [1,679 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 python3-setuptools-whl all 59.6.0-1.2ubuntu0.22.04.1 [788 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 python3.10-venv amd64 3.10.12-1~22.04.2 [5,724 B]
Get:4 http://in.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 python3-venv amd64 3.10.6-1~22.04 [1,038 B]
Fetched 2,474 kB in 3s (897 kB/s)        
Setting up python3-venv (3.10.6-1~22.04) ...

Step 7: Create a new python virtual environment by using the below command

root@linuxhelp:~# python3 -m venv testenv

Step 8: Once the virtual environment is created, run the below command to activate it.

root@linuxhelp:~# source testenv/bin/activate

Step 9: Now install Flask by using pip install command

(testenv) root@linuxhelp:~# pip install flask
Collecting flask
  Downloading flask-3.0.0-py3-none-any.whl (99 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 99.7/99.7 KB 1.1 MB/s eta 0:00:00
Collecting itsdangerous>=2.1.2
  Downloading itsdangerous-2.1.2-py3-none-any.whl (15 kB)
Collecting click>=8.1.3
  Downloading click-8.1.7-py3-none-any.whl (97 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.9/97.9 KB 7.5 MB/s eta 0:00:00
Collecting blinker>=1.6.2
  Downloading blinker-1.6.3-py3-none-any.whl (13 kB)
Collecting Werkzeug>=3.0.0
  Downloading werkzeug-3.0.1-py3-none-any.whl (226 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 226.7/226.7 KB 5.0 MB/s eta 0:00:00
Collecting Jinja2>=3.1.2
  Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.1/133.1 KB 7.0 MB/s eta 0:00:00
Collecting MarkupSafe>=2.0
  Downloading MarkupSafe-2.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
Installing collected packages: MarkupSafe, itsdangerous, click, blinker, Werkzeug, Jinja2, flask
Successfully installed Jinja2-3.1.2 MarkupSafe-2.1.3 Werkzeug-3.0.1 blinker-1.6.3 click-8.1.7 flask-3.0.0 itsdangerous-2.1.2

Step 10: After the installation check the version of the flask by using the below command

(testenv) root@linuxhelp:~# flask --version
Python 3.10.12
Flask 3.0.0
Werkzeug 3.0.1

Step 11: Now create a simple Python code file that will import Flash to print a simple Hello message by using the below command.

(testenv) root@linuxhelp:~# vim flasktest.py
Add the lines in the python file
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
    return 'Hello, Flask!'
if __name__ == '__main__':
    app.run()

Step 12: Run the file by using the python command.

(testenv) root@linuxhelp:~# python3 flasktest.py
 * Serving Flask app 'flasktest'
 * Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:5000
Press CTRL+C to quit
127.0.0.1 - - [01/Nov/2023 08:03:11] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [01/Nov/2023 08:03:12] "GET /favicon.ico HTTP/1.1" 404 –

Now go to the browser and search the following link http:/127.0.0.1:5000 SNAP 1

You will see the above output in your browser

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to install Flask on Ubuntu 22.04. Your feedback is much welcome.

Tags:
michael
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What is Flask and why it is used?

A

Flask is a microweb framework that provides an API to build up web applications.

Q

What is the default host port and port of Flask?

A

The default local host of the flask is 127.0.0.1, and the default port is 5000.

Q

Why do we use Flask(__name__) in Flask?

A

The __name__ parameter is a Python built-in variable that is set to the name of the current module.

Q

What HTTP methods does Python Flask provide?

A

GET, POST, PUT, DELETE, HEAD

Q

How to install Flask Sijax?

A

Install Flask Sijax by using the following command pip install flask-sijax

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Ganesh Konka ?
Zentya 6.1 http proxy configuration

please send link for creating zentyal 6.1 for http proxy and firewall as gateway.

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.