Determining what version of Flask is installed

Question:

What’s the easiest way to determine which version of Flask is installed?

Asked By: Matthew Rankin

||

Answers:

As of flask 0.7 (June 28th, 2011), a __version__ attribute can be found on the flask module.

>> import flask
>> flask.__version__

Keep in mind that because prior to flask 0.7 there was no __version__ attribute, the preceding code will result in an attribute error on those older versions.

For versions older than flask 0.7, you might be able to determine it using pkg_resources as shown below:


>>> import pkg_resources
>>> pkg_resources.get_distribution('flask').version
'0.6.1'

This won’t work 100% though. It depends on the user having the pkg_resources library installed (it might come by default with a Linux distribution’s python installation, but since it’s not part of the standard library you can’t be positive), and also that the user installed flask in a way that pkg_resources can find it (for example, just copying the full flask source code into your directory puts it out of the range of pkg_resources).

Answered By: Mark Hildreth

Via the python interpreter.

>> import flask
>> flask.__version__
'0.7.2'

If flask was installed via pip or easy_install, you can always use the ‘pip freeze’ command.

Answered By: jpanganiban

More general way of doing it is :

pip freeze

It will list all installed python packages and their versions.
If you want to see just flask then try :

pip freeze | grep flask
Answered By: Saša Šijak

using dpkg:

dpkg -l | grep flask

output:

ii  python-flask 0.8-1 all micro web framework based on Werkzeug, Jinja2 and good intentions 
Answered By: Hackaholic

It’s quite simple !

In your terminal:

pip freeze | grep Flask

The output should be something like this:

Output: Flask==0.12
Answered By: user5683940

Tested whith Flask 1.0.2

Inside the venv run
flask --version

Answered By: lopezi
>>> import flask
>>> flask.__version__        #(To find the version)
'1.0.2'
>>> print flask.__file__     #(To find out the path where it is installed)
/usr/local/rnt/lib/python2.7/site-packages/flask/__init__.pyc
Answered By: Thulasiram Bandaru

If someone is trying to determine flask version via Anaconda Command Prompt then just run the following command:

flask --version

Above command will give following output format:

Python 3.7.3
Flask 1.1.1
Werkzeug 0.15.4
Answered By: Anshul Singhal

If managing with pip can just use list command to see all the packages and versions

pip list

Answered By: Jimmy Long

Just type:

python -m flask --version

Output:

Python 3.7.2 
Flask 1.1.1 
Werkzeug 0.16.0
Answered By: alxdx

Update on Flask version 1.1.2

  1. If Flask not installed then go to the required conda environment and write:
$ conda activate "name of conda environment" //py3 in my case
(py3)$ conda install flask
  1. Post installation check the version with command:
(py3)$ flask --version

Please Note: __version__ is not an attribute of flask anymore for the latest versions and thus flask.__version__ would throw an error

Terminal Output

(py3) xxxxxx@xxxxx:~$ flask --version
Python 3.7.7
Flask 1.1.2
Werkzeug 1.0.1
Answered By: hundredmiles

Type flask --version in your interpreter, for example: enter image description here

Answered By: Zain Ul Abideen
pip show fastapi uvicorn

Output :

Name: fastapi
Version: 0.75.0
Summary: FastAPI framework, high performance, easy to learn, fast to code, ready for production
Home-page: https://github.com/tiangolo/fastapi
Author: Sebastián Ramírez
Author-email: [email protected]
License: None
Location: /home/mind/Desktop/FASTAPIBasic-/fastenv/lib/python3.8/site-packages
Requires: starlette, pydantic
Required-by: 
---
Name: uvicorn
Version: 0.17.6
Summary: The lightning-fast ASGI server.
Home-page: https://www.uvicorn.org/
Author: Tom Christie
Author-email: [email protected]
License: BSD
Location: /home/mind/Desktop/FASTAPIBasic-/fastenv/lib/python3.8/site-packages
Requires: h11, click, asgiref
Required-by: 
Answered By: Arti
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.