Determining what version of Flask is installed

PythonFlask

Python Problem Overview


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

Python Solutions


Solution 1 - Python

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).

Solution 2 - Python

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

Solution 3 - Python

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.

Solution 4 - Python

It's quite simple !

In your terminal:

pip freeze | grep Flask

The output should be something like this:

Output: Flask==0.12

Solution 5 - Python

Tested whith Flask 1.0.2

Inside the venv run flask --version

Solution 6 - Python

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

Solution 7 - Python

using dpkg:

dpkg -l | grep flask

output:

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

Solution 8 - Python

>>> 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

Solution 9 - Python

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

pip list

Solution 10 - Python

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

Solution 11 - Python

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

Solution 12 - Python

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: 

Solution 13 - Python

Just type:

python -m flask --version

Output:

Python 3.7.2 
Flask 1.1.1 
Werkzeug 0.16.0

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMatthew RankinView Question on Stackoverflow
Solution 1 - PythonMark HildrethView Answer on Stackoverflow
Solution 2 - PythonSaša ŠijakView Answer on Stackoverflow
Solution 3 - PythonjpanganibanView Answer on Stackoverflow
Solution 4 - Pythonuser5683940View Answer on Stackoverflow
Solution 5 - PythonlopeziView Answer on Stackoverflow
Solution 6 - PythonAnshul SinghalView Answer on Stackoverflow
Solution 7 - PythonHackaholicView Answer on Stackoverflow
Solution 8 - PythonThulasiram BandaruView Answer on Stackoverflow
Solution 9 - PythonJimmy LongView Answer on Stackoverflow
Solution 10 - PythonhundredmilesView Answer on Stackoverflow
Solution 11 - PythonZain Ul AbideenView Answer on Stackoverflow
Solution 12 - PythonArtiView Answer on Stackoverflow
Solution 13 - PythonalxdxView Answer on Stackoverflow