• 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 Debian 12

  • 00:27 lsb_release -a
  • 00:37 python3 --version
  • 00:46 pip -V
  • 01:00 apt install python3-pip -y
  • 01:10 pip -V
  • 01:21 apt install python3-venv
  • 01:39 python3 -m venv testenv
  • 01:51 source testenv/bin/activate
  • 01:58 pip install flask
  • 02:10 flask --version
  • 02:22 vim flasktest.py
  • 03:00 python3 flasktest.py
{{postValue.id}}

To Install Flask On Debian 12

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 steps

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

root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 12 (bookworm)
Release:	12
Codename:	bookworm

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

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

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

root@linuxhelp:~# pip -V
bash: pip: command not found

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 additional packages will be installed:
  libexpat1-dev libjs-jquery libjs-sphinxdoc libjs-underscore libpython3-dev
  libpython3.11-dev python3-dev python3-setuptools python3-wheel
  python3.11-dev
Suggested packages:
  python-setuptools-doc
The following NEW packages will be installed:
  libexpat1-dev libjs-jquery libjs-sphinxdoc libjs-underscore libpython3-dev
  libpython3.11-dev python3-dev python3-pip python3-setuptools python3-wheel
  python3.11-dev
0 upgraded, 11 newly installed, 0 to remove and 106 not upgraded.
Need to get 7,987 kB of archives.
After this operation, 38.9 MB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bookworm/main amd64 libexpat1-dev amd64 2.5.0-1 [150 kB]
Get:2 http://deb.debian.org/debian bookworm/main amd64 libjs-jquery all 3.6.1+dfsg+~3.5.14-1 [326 kB]
Get:3 http://deb.debian.org/debian bookworm/main amd64 libjs-underscore all 1.13.4~dfsg+~1.11.4-3 [116 kB]
Get:4 http://deb.debian.org/debian bookworm/main amd64 libjs-sphinxdoc all 5.3.0-4 [130 kB]
Get:5 http://deb.debian.org/debian bookworm/main amd64 libpython3.11-dev amd64 3.11.2-6 [4,738 kB]
Get:6 http://deb.debian.org/debian bookworm/main amd64 libpython3-dev amd64 3.11.2-1+b1 [9,572 B]
Get:7 http://deb.debian.org/debian bookworm/main amd64 python3.11-dev amd64 3.11.2-6 [615 kB]
Get:8 http://deb.debian.org/debian bookworm/main amd64 python3-dev amd64 3.11.2-1+b1 [26.2 kB]
Get:9 http://deb.debian.org/debian bookworm/main amd64 python3-setuptools all 66.1.1-1 [521 kB]
Get:10 http://deb.debian.org/debian bookworm/main amd64 python3-wheel all 0.38.4-2 [30.8 kB]
Get:11 http://deb.debian.org/debian bookworm/main amd64 python3-pip all 23.0.1+dfsg-1 [1,325 kB]
Fetched 7,987 kB in 1s (7,212 kB/s)     
Selecting previously unselected package libexpat1-dev:amd64.
(Reading database ... 177231 files and directories currently installed.)
Preparing to unpack .../00-libexpat1-dev_2.5.0-1_amd64.deb ...
Unpacking libexpat1-dev:amd64 (2.5.0-1) ...
Selecting previously unselected package libjs-jquery.
Preparing to unpack .../01-libjs-jquery_3.6.1+dfsg+~3.5.14-1_all.deb ...
Unpacking libjs-jquery (3.6.1+dfsg+~3.5.14-1) ...
Selecting previously unselected package libjs-underscore.
Preparing to unpack .../02-libjs-underscore_1.13.4~dfsg+~1.11.4-3_all.deb ...
Unpacking libjs-underscore (1.13.4~dfsg+~1.11.4-3) ...
Selecting previously unselected package libjs-sphinxdoc.
Preparing to unpack .../03-libjs-sphinxdoc_5.3.0-4_all.deb ...
Unpacking libjs-sphinxdoc (5.3.0-4) ...
Selecting previously unselected package libpython3.11-dev:amd64.
Preparing to unpack .../04-libpython3.11-dev_3.11.2-6_amd64.deb ...
Unpacking libpython3.11-dev:amd64 (3.11.2-6) ...
Selecting previously unselected package libpython3-dev:amd64.
Preparing to unpack .../05-libpython3-dev_3.11.2-1+b1_amd64.deb ...
Unpacking libpython3-dev:amd64 (3.11.2-1+b1) ...
Selecting previously unselected package python3.11-dev.
Preparing to unpack .../06-python3.11-dev_3.11.2-6_amd64.deb ...
Unpacking python3.11-dev (3.11.2-6) ...
Selecting previously unselected package python3-dev.
Preparing to unpack .../07-python3-dev_3.11.2-1+b1_amd64.deb ...
Unpacking python3-dev (3.11.2-1+b1) ...
Selecting previously unselected package python3-setuptools.
Preparing to unpack .../08-python3-setuptools_66.1.1-1_all.deb ...
Unpacking python3-setuptools (66.1.1-1) ...
Selecting previously unselected package python3-wheel.
Preparing to unpack .../09-python3-wheel_0.38.4-2_all.deb ...
Unpacking python3-wheel (0.38.4-2) ...
Selecting previously unselected package python3-pip.
Preparing to unpack .../10-python3-pip_23.0.1+dfsg-1_all.deb ...
Unpacking python3-pip (23.0.1+dfsg-1) ...
Setting up python3-setuptools (66.1.1-1) ...
Setting up python3-wheel (0.38.4-2) ...
Setting up libexpat1-dev:amd64 (2.5.0-1) ...
Setting up libpython3.11-dev:amd64 (3.11.2-6) ...
Setting up python3-pip (23.0.1+dfsg-1) ...
Setting up libjs-jquery (3.6.1+dfsg+~3.5.14-1) ...
Setting up libjs-underscore (1.13.4~dfsg+~1.11.4-3) ...
Setting up libpython3-dev:amd64 (3.11.2-1+b1) ...
Setting up python3.11-dev (3.11.2-6) ...
Setting up libjs-sphinxdoc (5.3.0-4) ...
Setting up python3-dev (3.11.2-1+b1) ...
Processing triggers for man-db (2.11.2-2) ...

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

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

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 additional packages will be installed:
  python3-pip-whl python3-setuptools-whl python3.11-venv
The following NEW packages will be installed:
  python3-pip-whl python3-setuptools-whl python3-venv python3.11-venv
0 upgraded, 4 newly installed, 0 to remove and 106 not upgraded.
Need to get 2,836 kB of archives.
After this operation, 3,170 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://deb.debian.org/debian bookworm/main amd64 python3-pip-whl all 23.0.1+dfsg-1 [1,717 kB]
Get:2 http://deb.debian.org/debian bookworm/main amd64 python3-setuptools-whl all 66.1.1-1 [1,111 kB]
Get:3 http://deb.debian.org/debian bookworm/main amd64 python3.11-venv amd64 3.11.2-6 [5,892 B]
Get:4 http://deb.debian.org/debian bookworm/main amd64 python3-venv amd64 3.11.2-1+b1 [1,200 B]
Fetched 2,836 kB in 1s (4,111 kB/s)      
Selecting previously unselected package python3-pip-whl.
(Reading database ... 178485 files and directories currently installed.)
Preparing to unpack .../python3-pip-whl_23.0.1+dfsg-1_all.deb ...
Unpacking python3-pip-whl (23.0.1+dfsg-1) ...
Selecting previously unselected package python3-setuptools-whl.
Preparing to unpack .../python3-setuptools-whl_66.1.1-1_all.deb ...
Unpacking python3-setuptools-whl (66.1.1-1) ...
Selecting previously unselected package python3.11-venv.
Preparing to unpack .../python3.11-venv_3.11.2-6_amd64.deb ...
Unpacking python3.11-venv (3.11.2-6) ...
Selecting previously unselected package python3-venv.
Preparing to unpack .../python3-venv_3.11.2-1+b1_amd64.deb ...
Unpacking python3-venv (3.11.2-1+b1) ...
Setting up python3-setuptools-whl (66.1.1-1) ...
Setting up python3-pip-whl (23.0.1+dfsg-1) ...
Setting up python3.11-venv (3.11.2-6) ...
Setting up python3-venv (3.11.2-1+b1) ...

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.3-py3-none-any.whl (101 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 101.7/101.7 kB 1.2 MB/s eta 0:00:00
Collecting Werkzeug>=3.0.0
  Downloading werkzeug-3.0.3-py3-none-any.whl (227 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 227.3/227.3 kB 3.5 MB/s eta 0:00:00
Collecting Jinja2>=3.1.2
  Downloading jinja2-3.1.4-py3-none-any.whl (133 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.3/133.3 kB 21.2 MB/s eta 0:00:00
Collecting itsdangerous>=2.1.2
  Downloading itsdangerous-2.2.0-py3-none-any.whl (16 kB)
Collecting click>=8.1.3
  Downloading click-8.1.7-py3-none-any.whl (97 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.9/97.9 kB 9.0 MB/s eta 0:00:00
Collecting blinker>=1.6.2
  Downloading blinker-1.8.2-py3-none-any.whl (9.5 kB)
Collecting MarkupSafe>=2.0
  Downloading MarkupSafe-2.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (28 kB)
Installing collected packages: MarkupSafe, itsdangerous, click, blinker, Werkzeug, Jinja2, flask
Successfully installed Jinja2-3.1.4 MarkupSafe-2.1.5 Werkzeug-3.0.3 blinker-1.8.2 click-8.1.7 flask-3.0.3 itsdangerous-2.2.0

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

(testenv) root@linuxhelp:~# flask --version
Python 3.11.2
Flask 3.0.3
Werkzeug 3.0.3

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
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 - - [14/May/2024 04:04:16] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [14/May/2024 04:04:16] "GET /favicon.ico HTTP/1.1" 404 -

Step 13: Now go to the browser and search the following link http:/127.0.0.1:5000 snap 1

Conclusion:

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

Tags:
ethan
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What is Flask and why it’s 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 Elijah ?
Remote Desktop Connection Has Stopped Working

When accessing my remote machine server using remote desktop on a windows machine I am getting this error

forum (1)

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.